Avoid RuntimeError caused by iteration over sys.modules
As is described in the doc[1], we should not iterate over sys.modules directly because sys.modules can be changed during iterations. [1] https://docs.python.org/3/library/sys.html#sys.modules Change-Id: Ib6ab36f93b408fdae59c1c08146f2ca069ed4f96
This commit is contained in:
parent
ecdeadeb7a
commit
6410ca6518
|
@ -163,7 +163,7 @@ class YaqlEvaluatorTest(base.BaseTest):
|
|||
def test_function_json_pp_deprecation(self):
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
# Ensure warnings aren't suppressed from other tests.
|
||||
for name, mod in list(sys.modules.items()):
|
||||
for name, mod in list(sys.modules.copy().items()):
|
||||
getattr(mod, '__warningregistry__', dict()).clear()
|
||||
|
||||
warnings.simplefilter('always')
|
||||
|
|
Loading…
Reference in New Issue