From bb7a42a99f245ef67dd261866188b0fe6f9fad07 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Mon, 9 Jul 2012 19:35:24 -0700 Subject: [PATCH] run_all_tests: added script to run all tests --- interfaces/python/run_all_tests | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 interfaces/python/run_all_tests diff --git a/interfaces/python/run_all_tests b/interfaces/python/run_all_tests new file mode 100755 index 00000000..17233ab6 --- /dev/null +++ b/interfaces/python/run_all_tests @@ -0,0 +1,20 @@ +#! /usr/bin/python + +if __name__ == '__main__': + import os, sys, unittest + 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') -- 2.26.2