New submission from blhsing <blhs...@gmail.com>:
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 <rep...@bugs.python.org> <https://bugs.python.org/issue37972> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com