From 4cca787aea08e837bba45d07d879e59c8235f1d1 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Sat, 13 Apr 2013 11:36:54 -0500 Subject: [PATCH] tests/run_all_tests: rewrite alltests.py --- tests/alltests.py | 10 ---------- tests/run_all_tests | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 10 deletions(-) delete mode 100644 tests/alltests.py create mode 100755 tests/run_all_tests diff --git a/tests/alltests.py b/tests/alltests.py deleted file mode 100644 index c79f628..0000000 --- a/tests/alltests.py +++ /dev/null @@ -1,10 +0,0 @@ -from testcomponent import * -from testinputadapter import * -from testdecoding import * -from testgraphing import * -from testanalyzing import * -from testencoding import * -from testtranscoding import * -from unit_timeside import * - -unittest.main(testRunner=TestRunner()) diff --git a/tests/run_all_tests b/tests/run_all_tests new file mode 100755 index 0000000..444c1db --- /dev/null +++ b/tests/run_all_tests @@ -0,0 +1,21 @@ +#! /usr/bin/env python + +if __name__ == '__main__': + import os, sys, unittest + from unit_timeside import * + def load_test(): + # get relevant files + curdir = os.path.dirname(sys.argv[0]) + if curdir == '': curdir = '.' + files = os.listdir(curdir) + modfiles = filter (lambda y: y.endswith('.py'), files) + modfiles = filter (lambda f: f.startswith('test'), modfiles) + # get module names + modnames = map (lambda x: os.path.splitext(x)[0], modfiles) + # import them + modules = map (__import__, modnames) + # create a test suites from the imported module + load_from_module = unittest.defaultTestLoader.loadTestsFromModule + tests = map(load_from_module, modules) + return unittest.TestSuite(tests) + unittest.main(defaultTest = 'load_test', testRunner=TestRunner()) -- 2.39.5