Message295335
Mock can accept a spec object / class as argument, making sure that accessing attributes that do not exist in the spec will cause an AttributeError to be raised, but there is no guarantee that the spec's methods signatures are respected in any way. This creates the possibility to have faulty code with passing unittests and assertions.
Steps to reproduce:
>>> import mock
>>>
>>> class Something(object):
... def foo(self, a, b, c, d):
... pass
...
>>>
>>> m = mock.Mock(spec=Something)
>>> m.foo()
<Mock name='mock.foo()' id='140286904787240'>
>>> # TypeError should be raised, but it isn't.
...
>>> m.foo.assert_called_once_with()
Expected behaviour: It should have raised a TypeError, since the method signature is: def meth(self, a, b, c, d):
Actual behaviour: No error. |
|
Date |
User |
Action |
Args |
2017-06-07 12:04:07 | cbelu | set | recipients:
+ cbelu |
2017-06-07 12:04:06 | cbelu | set | messageid: <1496837046.98.0.920527641247.issue30587@psf.upfronthosting.co.za> |
2017-06-07 12:04:06 | cbelu | link | issue30587 messages |
2017-06-07 12:04:06 | cbelu | create | |
|