run all test suites, if called as main

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-10-14 14:16:15 +02:00
parent 97da16f4bc
commit 6d7620582d

View file

@ -1,4 +1,3 @@
#c1406:!/usr/bin/env python3
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
@ -36,16 +35,14 @@ for possible_test in os.listdir(base_dir):
if os.path.isfile(mod_path): if os.path.isfile(mod_path):
test_modules.append(possible_test) test_modules.append(possible_test)
print(sys.path)
suites = [] suites = []
for test_module in test_modules: for test_module in test_modules:
module = imp.find_module(test_module, [base_dir]) module_parameters = imp.find_module(test_module, [base_dir])
imp.load_module(test_module, *module) module = imp.load_module("cdist.test." + test_module, *module_parameters)
print(module) suite = unittest.defaultTestLoader.loadTestsFromModule(module)
# module_name = # print("Got suite: " + suite.__str__())
suite = unittest.defaultTestLoader.loadTestsFromModule("cdist.test." + test_module)
suites.append(suite) suites.append(suite)
all_suites = unittest.TestSuite(suites)
unittest.TextTestRunner(verbosity=2).run(all_suites)