Skip to content

Commit

Permalink
fix test runners
Browse files Browse the repository at this point in the history
  • Loading branch information
jrkerns committed Mar 19, 2016
1 parent 48d0219 commit 2aa7f47
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
10 changes: 10 additions & 0 deletions 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)
16 changes: 3 additions & 13 deletions 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)
4 changes: 2 additions & 2 deletions tests/_test_alls.py
Expand Up @@ -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')

0 comments on commit 2aa7f47

Please sign in to comment.