Skip to content

Commit

Permalink
Add exception handler
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbean-bremen committed Jan 11, 2024
1 parent 5a9c1e5 commit c873d56
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pyfakefs/fake_filesystem_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,11 @@ def cleanup(self) -> None:
for name in self._loaded_module_names:
if name in sys.modules and name not in reloaded_module_names:
print(f"Reload {name} patched: {name in Patcher.PATCHED_MODULE_NAMES}")
reload(sys.modules[name])
try:
reload(sys.modules[name])
except Exception:
print(f"Failed to reload - delete {name}")
del sys.modules[name]

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

0 comments on commit c873d56

Please sign in to comment.