[issue26704] unittest.mock.patch: Double patching instance method: AttributeError: Mock object has no attribute '__name__'

Anthony Sottile report at bugs.python.org
Wed Apr 6 17:17:51 EDT 2016


Anthony Sottile added the comment:

The root cause seems to be that autospecced functions return a function object (not a Mock instance) which a '.mock' attribute which is a MagicMock ( assigned here: https://github.com/python/cpython/blob/ae775ab1eb72f42de2d070158bade4bf261ac04f/Lib/unittest/mock.py#L198 )

I took a first stab at a patch (attached)

----------
Added file: http://bugs.python.org/file42384/patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26704>
_______________________________________


More information about the Python-bugs-list mailing list