diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1972fc01..da6b76fe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,6 +25,6 @@ jobs: - name: Test built package run: | - pip install pytest + pip install pytest pytest-cov pip install ./target - pytest -v pipeline/tests + pytest -v --cov=openminds --cov-report term pipeline/tests diff --git a/pipeline/tests/test_instantiation.py b/pipeline/tests/test_instantiation.py index 45f85e1b..7cf93961 100644 --- a/pipeline/tests/test_instantiation.py +++ b/pipeline/tests/test_instantiation.py @@ -2,33 +2,39 @@ Tests for openMINDS Python module """ +from importlib import import_module +import sys + import pytest from openminds.base import Node, IRI -from openminds.latest import ( - chemicals, - computation, - controlled_terms, - core, - ephys, - publications, - sands, - specimen_prep, - stimulation, -) + from utils import build_fake_node -all_modules = ( - chemicals, - computation, - controlled_terms, - core, - ephys, - publications, - sands, - specimen_prep, - stimulation, +module_names = ( + "chemicals", + "computation", + "controlled_terms", + "core", + "ephys", + "publications", + "sands", + "specimen_prep", + "stimulation", ) +versions = ("v3", "v4", "latest") # "v1" and "v2" currently produce errors + +all_modules = [] +for version in versions: + for module_name in module_names: + path = f"openminds.{version}.{module_name}" + try: + module = import_module(path) + except ModuleNotFoundError: + continue + else: + sys.modules[path] = module + all_modules.append(module) def classes_in_module(module):