diff options
author | Karthikeyan Singaravelan <tir.karthi@gmail.com> | 2020-01-24 18:44:29 +0530 |
---|---|---|
committer | Chris Withers <chris@withers.org> | 2020-01-24 13:14:29 +0000 |
commit | 66b00a9d3aacf6ed49412f48743e4913104a2bb3 (patch) | |
tree | 2326feba1f39e3613e1eae1fd9c5822591c2480a /Lib/unittest/mock.py | |
parent | b8d1262e8afe7b907b4a394a191739571092acdb (diff) | |
download | cpython-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.py | 4 |
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 |