restructure project
This commit is contained in:
48
tests/test_imports.py
Normal file
48
tests/test_imports.py
Normal file
@@ -0,0 +1,48 @@
|
||||
"""Import validation tests.
|
||||
|
||||
Ensures all lazy imports across packages resolve correctly,
|
||||
catching cross-package import errors that mocks would hide.
|
||||
"""
|
||||
import importlib
|
||||
import pkgutil
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def _collect_modules(package_name: str) -> list[str]:
|
||||
"""Recursively collect all module names under a package."""
|
||||
try:
|
||||
package = importlib.import_module(package_name)
|
||||
except Exception:
|
||||
return [package_name]
|
||||
|
||||
modules = [package_name]
|
||||
if hasattr(package, "__path__"):
|
||||
for _importer, modname, _ispkg in pkgutil.walk_packages(
|
||||
package.__path__, prefix=package_name + "."
|
||||
):
|
||||
modules.append(modname)
|
||||
return modules
|
||||
|
||||
|
||||
SHARED_MODULES = _collect_modules("shared")
|
||||
INFERENCE_MODULES = _collect_modules("inference")
|
||||
TRAINING_MODULES = _collect_modules("training")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("module_name", SHARED_MODULES)
|
||||
def test_shared_module_imports(module_name: str) -> None:
|
||||
"""Every module in the shared package should import without error."""
|
||||
importlib.import_module(module_name)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("module_name", INFERENCE_MODULES)
|
||||
def test_inference_module_imports(module_name: str) -> None:
|
||||
"""Every module in the inference package should import without error."""
|
||||
importlib.import_module(module_name)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("module_name", TRAINING_MODULES)
|
||||
def test_training_module_imports(module_name: str) -> None:
|
||||
"""Every module in the training package should import without error."""
|
||||
importlib.import_module(module_name)
|
||||
Reference in New Issue
Block a user