diff --git a/tests/__init__.py b/tests/__init__.py index 22d8c659e..64148ca94 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,4 +1,14 @@ import os.path as osp +import unittest TEST_FILES_DIR = osp.abspath(osp.join(osp.dirname(__file__), 'test_files')) TEST_BANK_DIR = osp.abspath(osp.join(osp.dirname(__file__), '..', '..', 'pylinac test files')) + + +def run_tests(directory, pattern='test*.py'): + # import a runner to run tests + runner = unittest.TextTestRunner() + # run test discovery + test_suite = unittest.defaultTestLoader.discover(directory, pattern) + # run test runner + runner.run(test_suite) \ No newline at end of file diff --git a/tests/_test_all.py b/tests/_test_all.py index 1785e226e..38b226d39 100644 --- a/tests/_test_all.py +++ b/tests/_test_all.py @@ -1,17 +1,7 @@ """Test the entire package; an underscore precedes this file name so it does not include itself in the test discovery.""" -import unittest import os.path as osp +from . import run_tests - -def run(directory, pattern='test*.py'): - # import a runner to run tests - runner = unittest.TextTestRunner() - # run test discovery - test_suite = unittest.defaultTestLoader.discover(directory, pattern) - # run test runner - runner.run(test_suite) - -if __name__ == "__main__": - test_dir = osp.dirname(__file__) - run(test_dir) +test_dir = osp.dirname(__file__) +run_tests(test_dir) diff --git a/tests/_test_alls.py b/tests/_test_alls.py index 84d94163b..e0a403630 100644 --- a/tests/_test_alls.py +++ b/tests/_test_alls.py @@ -2,8 +2,8 @@ but accesses the larger, private test data.""" import os.path as osp -from tests._test_all import run +from tests import run_tests test_dir = osp.dirname(__file__) -run(test_dir, pattern='_test_all_*.py') +run_tests(test_dir, pattern='_test_all_*.py')