bpo-38473: Handle autospecced functions and methods used with attach_mock (GH-16784)

This commit is contained in:
Karthikeyan Singaravelan 2020-01-24 18:44:29 +05:30 committed by Chris Withers
parent b8d1262e8a
commit 66b00a9d3a
3 changed files with 35 additions and 0 deletions

View file

@ -817,6 +817,10 @@ class NonCallableMock(Base):
if child is None or isinstance(child, _SpecState):
break
else:
# If an autospecced object is attached using attach_mock the
# child would be a function with mock object as attribute from
# which signature has to be derived.
child = _extract_mock(child)
children = child._mock_children
sig = child._spec_signature