diff options
author | Xtreak <tir.karthi@gmail.com> | 2019-02-25 21:46:34 (GMT) |
---|---|---|
committer | Chris Withers <chris@withers.org> | 2019-02-25 21:46:34 (GMT) |
commit | 9c3f284de598550be6687964c23fd7599e53b20e (patch) | |
tree | a873c7a0f55f9a1d2c3fdf00476e7bd24563e1cd /Lib/unittest/mock.py | |
parent | f1b9abe35f75393351b3d954a392122a3f8f6951 (diff) | |
download | cpython-9c3f284de598550be6687964c23fd7599e53b20e.zip cpython-9c3f284de598550be6687964c23fd7599e53b20e.tar.gz cpython-9c3f284de598550be6687964c23fd7599e53b20e.tar.bz2 |
Autospec functions should propagate mock calls to parent GH-11273
Diffstat (limited to 'Lib/unittest/mock.py')
-rw-r--r-- | Lib/unittest/mock.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py index ccbcd35..2ccf0d8 100644 --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -321,6 +321,14 @@ class _CallList(list): def _check_and_set_parent(parent, value, name, new_name): + # function passed to create_autospec will have mock + # attribute attached to which parent must be set + if isinstance(value, FunctionTypes): + try: + value = value.mock + except AttributeError: + pass + if not _is_instance_mock(value): return False if ((value._mock_name or value._mock_new_name) or |