New submission from Anthony Sottile: Originally from https://github.com/testing-cabal/mock/issues/350
## Example ```python from unittest 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): pass ``` ## Python3.3 ``` $ test.py $ ``` ## Python3.4 / 3.5 / 3.6 (From gitbhub.com/python/cpython@fa3fc6d7) ``` Traceback (most recent call last): File "test.py", line 10, in <module> with mock.patch.object(c, 'f', autospec=True): File "/home/asottile/workspace/cpython/Lib/unittest/mock.py", line 1320, in __enter__ _name=self.attribute, **kwargs) File "/home/asottile/workspace/cpython/Lib/unittest/mock.py", line 2220, in create_autospec _check_signature(original, new, skipfirst=skipfirst) File "/home/asottile/workspace/cpython/Lib/unittest/mock.py", line 112, in _check_signature _copy_func_details(func, checksig) File "/home/asottile/workspace/cpython/Lib/unittest/mock.py", line 117, in _copy_func_details funcopy.__name__ = func.__name__ File "/home/asottile/workspace/cpython/Lib/unittest/mock.py", line 578, in __getattr__ raise AttributeError("Mock object has no attribute %r" % name) AttributeError: Mock object has no attribute '__name__' ``` ---------- components: Library (Lib) messages: 262960 nosy: asottile priority: normal severity: normal status: open title: unittest.mock.patch: Double patching instance method: AttributeError: Mock object has no attribute '__name__' type: crash versions: Python 3.4, Python 3.5, Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26704> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com