From f3074a3ced8d8a079c9050aeb64551ddd869641d Mon Sep 17 00:00:00 2001 From: Karl Chen Date: Tue, 24 Aug 2021 19:10:08 -0400 Subject: [PATCH] Fix RuntimeError: dictionary changed size during iteration --- conftest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conftest.py b/conftest.py index a92e19d1..f242ec35 100644 --- a/conftest.py +++ b/conftest.py @@ -81,7 +81,7 @@ def flush(self): if in_tox: # When in tox, we shouldn't have any usercustomize messing this up. - for k in sys.modules.keys(): + for k in list(sys.modules.keys()): assert not k == "pyflyby" or k.startswith("pyflyby.") import pyflyby @@ -92,7 +92,7 @@ def flush(self): # Unload any already-imported pyflyby. This could happen if the user's # usercustomize imported pyflyby. That would probably be the "production" # pyflyby rather than the one being developed & tested. - for k in sys.modules.keys(): + for k in list(sys.modules.keys()): if k == "pyflyby" or k.startswith("pyflyby."): del sys.modules[k]