Author cbelu
Recipients cbelu
Date 2017-06-07.12:04:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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)
<Mock name='' id='140286904787240'>
>>> # TypeError should be raised, but it isn't.

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:07cbelusetrecipients: + cbelu
2017-06-07 12:04:06cbelusetmessageid: <>
2017-06-07 12:04:06cbelulinkissue30587 messages
2017-06-07 12:04:06cbelucreate