From 3b182c3be32edba3f7c20c1dc2a9f353387eb499 Mon Sep 17 00:00:00 2001 From: Christopher Rhodes <christopher.rhodes@embl.de> Date: Thu, 4 Jul 2024 18:21:48 +0200 Subject: [PATCH] Started a startup-script for tests to find test data --- conda-recipe/meta.yaml | 2 ++ tests/_conf.py | 6 ++++-- tests/run_tests.py | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 tests/run_tests.py diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index d150dc85..39965c5e 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -37,6 +37,8 @@ test: imports: - model_server commands: +# - echo {{ PREFIX }} +# - set PYTHON_UNITTEST_DATA_ROOT = "{{ PREFIX }}" - python -m unittest discover requires: - pip diff --git a/tests/_conf.py b/tests/_conf.py index 61c211af..22afb0cd 100644 --- a/tests/_conf.py +++ b/tests/_conf.py @@ -2,9 +2,11 @@ import os from pathlib import Path root = os.environ.get( - 'PYTHON_UNITTEST_OUTPUT', - Path.home() / 'model_server' / 'testing' + 'PYTHON_UNITTEST_DATA_ROOT', + # Path.home() / 'model_server' / 'testing' ) +if root == None: + raise Exception('data directory not specified') filename = 'D3-selection-01.czi' czifile = { diff --git a/tests/run_tests.py b/tests/run_tests.py new file mode 100644 index 00000000..a4a2420b --- /dev/null +++ b/tests/run_tests.py @@ -0,0 +1,14 @@ +import os +from pathlib import Path +import sys +import unittest + +pa = Path(__file__).parent +runner = unittest.TextTestRunner() + +if __name__ == '__main__': + # takes path to test data as first argument + data_dir_arg = sys.argv[1] + data_dir = (Path(os.getcwd()) / sys.argv[1]).resolve() + assert data_dir.exists(), f'Could not find test data' + runner.run(unittest.TestLoader().discover(data_dir)) \ No newline at end of file -- GitLab