Message252276
>>> from unittest import mock
>>>
>>> class Foo:
... def __init__(self, val):
... pass
... def func(self):
... pass
...
>>> class FooMock(mock.Mock):
... def _get_child_mock(self, **kwargs):
... return mock.Mock(spec_set=Foo)
...
>>> mock_foo = FooMock()
>>> mock_foo.func()
<Mock name='mock()' id='4340652632'>
>>> mock_foo.func.mock_calls
[call()]
>>> mock_foo.func.assert_has_calls([mock.call()])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.5/unittest/mock.py", line 824, in assert_has_calls
) from cause
AssertionError: Calls not found.
Expected: [call()]
Actual: [call()]
While this code is expected to fail (FooMock.func is set to an incorrect spec), the error message is misleading and does not make any sense. |
|
Date |
User |
Action |
Args |
2015-10-04 18:07:08 | uranusjr | set | recipients:
+ uranusjr |
2015-10-04 18:07:08 | uranusjr | set | messageid: <1443982028.68.0.922333733292.issue25312@psf.upfronthosting.co.za> |
2015-10-04 18:07:08 | uranusjr | link | issue25312 messages |
2015-10-04 18:07:08 | uranusjr | create | |
|