mirror of
https://github.com/python/cpython.git
synced 2025-09-12 11:46:52 +00:00
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:
parent
aeca373b33
commit
a875ea58b2
4 changed files with 25 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue