- Notifications
You must be signed in to change notification settings - Fork 105
Closed
Labels
Description
Example
import mock class C(object): def f(self): pass c = C() with mock.patch.object(c, 'f', autospec=True): with mock.patch.object(c, 'f', autospec=True): passmock 1.3 / 2.0
# python test.py Traceback (most recent call last): File "test.py", line 10, in <module> with mock.patch.object(c, 'f', autospec=True): File "/nail/home/asottile/pg/yelp-main/virtualenv_run/lib/python2.7/site-packages/mock/mock.py", line 1450, in __enter__ _name=self.attribute, **kwargs) File "/nail/home/asottile/pg/yelp-main/virtualenv_run/lib/python2.7/site-packages/mock/mock.py", line 2370, in create_autospec _check_signature(original, new, skipfirst=skipfirst) File "/nail/home/asottile/pg/yelp-main/virtualenv_run/lib/python2.7/site-packages/mock/mock.py", line 210, in _check_signature _copy_func_details(func, checksig) File "/nail/home/asottile/pg/yelp-main/virtualenv_run/lib/python2.7/site-packages/mock/mock.py", line 215, in _copy_func_details funcopy.__name__ = func.__name__ File "/nail/home/asottile/pg/yelp-main/virtualenv_run/lib/python2.7/site-packages/mock/mock.py", line 698, in __getattr__ raise AttributeError("Mock object has no attribute %r" % name) AttributeError: Mock object has no attribute '__name__'mock 1.0.1
# python test.py #