Avoid double loop in subprocess_context.store_patches (#25621)
fixes #21643 As far as I can see the double loop is not needed, since "patch" is never used and the items in the list are tuples of three values.
This commit is contained in:
parent
1ab6f30fdd
commit
a3d8e95e76
1 changed files with 9 additions and 10 deletions
|
@ -139,16 +139,15 @@ def store_patches():
|
||||||
class_patches = list()
|
class_patches = list()
|
||||||
if not patches:
|
if not patches:
|
||||||
return TestPatches(list(), list())
|
return TestPatches(list(), list())
|
||||||
for patch in patches:
|
for target, name, _ in patches:
|
||||||
for target, name, _ in patches:
|
if isinstance(target, ModuleType):
|
||||||
if isinstance(target, ModuleType):
|
new_val = getattr(target, name)
|
||||||
new_val = getattr(target, name)
|
module_name = target.__name__
|
||||||
module_name = target.__name__
|
module_patches.append((module_name, name, new_val))
|
||||||
module_patches.append((module_name, name, new_val))
|
elif isinstance(target, type):
|
||||||
elif isinstance(target, type):
|
new_val = getattr(target, name)
|
||||||
new_val = getattr(target, name)
|
class_fqn = '.'.join([target.__module__, target.__name__])
|
||||||
class_fqn = '.'.join([target.__module__, target.__name__])
|
class_patches.append((class_fqn, name, new_val))
|
||||||
class_patches.append((class_fqn, name, new_val))
|
|
||||||
|
|
||||||
return TestPatches(module_patches, class_patches)
|
return TestPatches(module_patches, class_patches)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue