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:
Massimiliano Culpo 2021-08-26 18:46:01 +02:00 committed by GitHub
parent 1ab6f30fdd
commit a3d8e95e76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -139,16 +139,15 @@ def store_patches():
class_patches = list()
if not patches:
return TestPatches(list(), list())
for patch in patches:
for target, name, _ in patches:
if isinstance(target, ModuleType):
new_val = getattr(target, name)
module_name = target.__name__
module_patches.append((module_name, name, new_val))
elif isinstance(target, type):
new_val = getattr(target, name)
class_fqn = '.'.join([target.__module__, target.__name__])
class_patches.append((class_fqn, name, new_val))
for target, name, _ in patches:
if isinstance(target, ModuleType):
new_val = getattr(target, name)
module_name = target.__name__
module_patches.append((module_name, name, new_val))
elif isinstance(target, type):
new_val = getattr(target, name)
class_fqn = '.'.join([target.__module__, target.__name__])
class_patches.append((class_fqn, name, new_val))
return TestPatches(module_patches, class_patches)