Skip to content

Commit

Permalink
Delete and reload
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbean-bremen committed Jan 11, 2024
1 parent 0cd74d8 commit 6a3a552
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pyfakefs/fake_filesystem_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1091,15 +1091,15 @@ def cleanup(self) -> None:
reloaded_module_names = [
module.__name__ for module in self._patcher.modules_to_reload
]
# Reload all modules loaded and patched during the test, ensuring that
# Reload all modules loaded during the test, ensuring that
# no faked modules are referenced after the test.
modules_to_reload = []
for name in self._loaded_module_names:
if name in sys.modules and name not in reloaded_module_names:
# in the unlikely case that the cache is turned off,
# we have to reload all modules
# if not self._patcher.use_cache or name in Patcher.CACHED_MODULES:
reload(sys.modules[name])
# del sys.modules[name]
modules_to_reload.append(sys.modules[name])
del sys.modules[name]
for module in modules_to_reload:
reload(module)

def needs_patch(self, name: str) -> bool:
"""Check if the module with the given name shall be replaced."""
Expand Down

0 comments on commit 6a3a552

Please sign in to comment.