[issue37972] unittest.mock.call does not chain __getitem__ to another _Call object

2020-01-29 Thread Chris Withers


Chris Withers  added the comment:


New changeset db5e86adbce12350c26e7ffc2c6673369971a2dc by Chris Withers in 
branch 'master':
Get mock coverage back to 100% (GH-18228)
https://github.com/python/cpython/commit/db5e86adbce12350c26e7ffc2c6673369971a2dc


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37972] unittest.mock.call does not chain __getitem__ to another _Call object

2019-10-10 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Closing as fixed since PRs were merged. Thanks Ben.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37972] unittest.mock.call does not chain __getitem__ to another _Call object

2019-09-12 Thread Roundup Robot


Roundup Robot  added the comment:


New changeset db0d8a5b2c803d30d9df436e00b6627ec8e09a13 by Michael Foord (Miss 
Islington (bot)) in branch '3.8':
bpo-37972: unittest.mock._Call now passes on __getitem__ to the __getattr__ 
chaining so that call() can be subscriptable (GH-15565) (GH-15965)
https://github.com/python/cpython/commit/db0d8a5b2c803d30d9df436e00b6627ec8e09a13


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37972] unittest.mock.call does not chain __getitem__ to another _Call object

2019-09-11 Thread Roundup Robot


Roundup Robot  added the comment:


New changeset 72c359912d36705a94fca8b63d80451905a14ae4 by Michael Foord 
(blhsing) in branch 'master':
bpo-37972: unittest.mock._Call now passes on __getitem__ to the __getattr__ 
chaining so that call() can be subscriptable (GH-15565)
https://github.com/python/cpython/commit/72c359912d36705a94fca8b63d80451905a14ae4


--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37972] unittest.mock.call does not chain __getitem__ to another _Call object

2019-09-11 Thread miss-islington


Change by miss-islington :


--
pull_requests: +15598
pull_request: https://github.com/python/cpython/pull/15965

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37972] unittest.mock.call does not chain __getitem__ to another _Call object

2019-09-11 Thread Ben Hsing


Ben Hsing  added the comment:

Correction. I've now done this by delegating the resolution of attributes 
belonging to the tuple class to _Call.__getattr__ instead. Passed all build 
tests.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37972] unittest.mock.call does not chain __getitem__ to another _Call object

2019-09-11 Thread Ben Hsing


Change by Ben Hsing :


--
status: pending -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37972] unittest.mock.call does not chain __getitem__ to another _Call object

2019-09-11 Thread Ben Hsing


Ben Hsing  added the comment:

Agreed. I've submitted a new commit with the call chaining behavior now 
generalized for all dunder methods by delegating the resolution of all 
attributes not directly in the _Call object's __dict__ keys to the getattr 
method.

--
status: open -> pending

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37972] unittest.mock.call does not chain __getitem__ to another _Call object

2019-09-11 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

If we go ahead with this then we should also support other dunder methods of 
tuple like __setitem__ and so on.

--
nosy: +cjw296, mariocj89, michael.foord
versions:  -Python 2.7, Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37972] unittest.mock.call does not chain __getitem__ to another _Call object

2019-08-28 Thread Ben Hsing


Change by Ben Hsing :


--
keywords: +patch
pull_requests: +15240
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/15565

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37972] unittest.mock.call does not chain __getitem__ to another _Call object

2019-08-28 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37972] unittest.mock.call does not chain __getitem__ to another _Call object

2019-08-28 Thread blhsing


New submission from blhsing :

As reported on StackOverflow:
https://stackoverflow.com/questions/57636747/how-to-perform-assert-has-calls-for-a-getitem-call

The following code would output: [call(), call().foo(), 
call().foo().__getitem__('bar')]

from unittest.mock import MagicMock, call
mm = MagicMock()
mm().foo()['bar']
print(mm.mock_calls)

but trying to use that list with mm.assert_has_calls([call(), call().foo(), 
call().foo().__getitem__('bar')]) would result in:

TypeError: tuple indices must be integers or slices, not str

--
components: Library (Lib)
messages: 350688
nosy: Ben Hsing
priority: normal
severity: normal
status: open
title: unittest.mock.call does not chain __getitem__ to another _Call object
type: behavior
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com