Skip to content

Commit

Permalink
Check if module is present before removing it
Browse files Browse the repository at this point in the history
Apparently not all tests that add modules to the PAGE_REGISTRY also add
them to sys.modules.
  • Loading branch information
rnestler committed Aug 28, 2024
1 parent 9fd15d7 commit e5f2ddb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def clear_pages_state():
def init_pages_state():
"""Clear all global state that is used by pages feature."""
for page in dash._pages.PAGE_REGISTRY.values():
sys.modules.pop(page["module"])
if page["module"] in sys.modules:
sys.modules.pop(page["module"])
dash._pages.PAGE_REGISTRY.clear()
dash._pages.CONFIG.clear()
dash._pages.CONFIG.__dict__.clear()

0 comments on commit e5f2ddb

Please sign in to comment.