From 52f7de96cc937669e44cf856d015ce0263b991c7 Mon Sep 17 00:00:00 2001 From: Neclow Date: Wed, 23 Sep 2026 09:21:00 +0200 Subject: [PATCH] test: extend import smoke tests to pipeline modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Expand test_imports.py to discover and test both src/ and pipeline/ modules. Add yaml (pyyaml) to the optional packages skip list. Restore K_RANGE and RANDOM_SEED constants to src/_config.py — these were dropped during a prior refactor but are still imported by pipeline/clustering_grid.py. Co-Authored-By: Claude Opus 4.6 --- src/_config.py | 2 ++ tests/test_imports.py | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/_config.py b/src/_config.py index 1046ee0..11f4518 100644 --- a/src/_config.py +++ b/src/_config.py @@ -16,4 +16,6 @@ DEFAULT_N_JOBS: Final = 10 DEFAULT_FPS: Final = 25.0 DEFAULT_N_BIRDS: Final = 3 +K_RANGE: Final[range] = range(2, 13) LABEL_ORDER: Final = ["none", "worm", "locomotor", "social"] +RANDOM_SEED: Final[int] = 42 diff --git a/tests/test_imports.py b/tests/test_imports.py index dbacf55..ce0aea4 100644 --- a/tests/test_imports.py +++ b/tests/test_imports.py @@ -1,4 +1,4 @@ -"""Smoke-test that every src module imports without error. +"""Smoke-test that every src and pipeline module imports without error. Modules whose only failure is a missing optional dependency (torch, transformers, etc.) are skipped so the test suite stays useful in the @@ -10,7 +10,8 @@ import pytest -SRC_ROOT = Path(__file__).resolve().parent.parent / "src" +PROJECT_ROOT = Path(__file__).resolve().parent.parent +PACKAGE_ROOTS = [PROJECT_ROOT / "src", PROJECT_ROOT / "pipeline"] OPTIONAL_PACKAGES = frozenset({ "torch", @@ -29,16 +30,20 @@ "omegaconf", "motmetrics", "kmedoids", + "yaml", }) def _discover_modules(): - """Yield dotted module paths for every .py file under src/.""" - for py_file in sorted(SRC_ROOT.rglob("*.py")): - if py_file.name == "__init__.py": + """Yield dotted module paths for every .py file under src/ and pipeline/.""" + for root in PACKAGE_ROOTS: + if not root.exists(): continue - relative = py_file.relative_to(SRC_ROOT.parent) - yield str(relative.with_suffix("")).replace("/", ".") + for py_file in sorted(root.rglob("*.py")): + if py_file.name == "__init__.py": + continue + relative = py_file.relative_to(PROJECT_ROOT) + yield str(relative.with_suffix("")).replace("/", ".") def _is_optional_dep_missing(exc: ModuleNotFoundError) -> bool: