diff options
author | Xtreak <tir.karthi@gmail.com> | 2019-02-25 00:24:49 +0530 |
---|---|---|
committer | Chris Withers <chris@withers.org> | 2019-02-24 18:54:49 +0000 |
commit | a875ea58b29fbf510f9790ae1653eeaa47dc0de8 (patch) | |
tree | 076c625afd240521c200df9b98485846f32687a4 /Lib/unittest/mock.py | |
parent | aeca373b339e0ea9739536ce6b43bd90f3b89873 (diff) | |
download | cpython-git-a875ea58b29fbf510f9790ae1653eeaa47dc0de8.tar.gz |
bpo-35512: Resolve string target to patch.dict decorator during function call GH#12000
* Resolve string target to patch.dict during function call
* Add NEWS entry
* Remove unneeded call
* Restore original value for support.target and refactor assertions
* Add extra assertion to verify unpatched dict
Diffstat (limited to 'Lib/unittest/mock.py')
-rw-r--r-- | Lib/unittest/mock.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py index 8f46050462..ccbcd355ce 100644 --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -1620,8 +1620,6 @@ class _patch_dict(object): """ def __init__(self, in_dict, values=(), clear=False, **kwargs): - if isinstance(in_dict, str): - in_dict = _importer(in_dict) self.in_dict = in_dict # support any argument supported by dict(...) constructor self.values = dict(values) @@ -1662,6 +1660,8 @@ class _patch_dict(object): def _patch_dict(self): values = self.values + if isinstance(self.in_dict, str): + self.in_dict = _importer(self.in_dict) in_dict = self.in_dict clear = self.clear |