This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author blhsing
Recipients blhsing
Date 2019-08-28.20:33:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1567024381.55.0.529292089661.issue37972@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2019-08-28 20:33:01blhsingsetrecipients: + blhsing
2019-08-28 20:33:01blhsingsetmessageid: <1567024381.55.0.529292089661.issue37972@roundup.psfhosted.org>
2019-08-28 20:33:01blhsinglinkissue37972 messages
2019-08-28 20:33:01blhsingcreate