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 Jun 2, 2023
1 parent a95fb6d commit 3bb355b
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 3bb355b

Please sign in to comment.