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
This commit is contained in:
Xtreak 2019-02-25 00:24:49 +05:30 committed by Chris Withers
parent aeca373b33
commit a875ea58b2
4 changed files with 25 additions and 2 deletions

View file

@ -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