Skip to content

Commit

Permalink
Gracefully fail imports
Browse files Browse the repository at this point in the history
  • Loading branch information
crusaderky committed Sep 7, 2022
1 parent ca9c525 commit 43460fa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ def load_test_source() -> None:
tests being importable from this script.
"""
for fname in glob.iglob("tests/**/test_*.py", recursive=True):
mod = importlib.import_module(fname.replace("/", ".")[: -len(".py")])
try:
mod = importlib.import_module(fname.replace("/", ".")[: -len(".py")])
# Some pytest exceptions inherit directly from BaseException
except BaseException as e:
print(f"Could not import {fname}: {e.__class__.__name__}: {e}")
continue
tests = [a for a in dir(mod) if a.startswith("test_")]
for test in tests:
if (func := getattr(mod, test, None)) and callable(func):
Expand Down

0 comments on commit 43460fa

Please sign in to comment.