summaryrefslogtreecommitdiff
path: root/Lib/unittest/mock.py
diff options
context:
space:
mode:
authorKarthikeyan Singaravelan <tir.karthi@gmail.com>2020-01-24 18:44:29 +0530
committerChris Withers <chris@withers.org>2020-01-24 13:14:29 +0000
commit66b00a9d3aacf6ed49412f48743e4913104a2bb3 (patch)
tree2326feba1f39e3613e1eae1fd9c5822591c2480a /Lib/unittest/mock.py
parentb8d1262e8afe7b907b4a394a191739571092acdb (diff)
downloadcpython-git-66b00a9d3aacf6ed49412f48743e4913104a2bb3.tar.gz
bpo-38473: Handle autospecced functions and methods used with attach_mock (GH-16784)
Diffstat (limited to 'Lib/unittest/mock.py')
-rw-r--r--Lib/unittest/mock.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index 3fafe594c5..92b596f672 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -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