Mercurial > hgsubversion
changeset 1043:69a9fb45cad5
tests: consolidate all test-loading into the test runner
author | Dan Villiom Podlaski Christiansen <dan@cabo.dk> |
---|---|
date | Wed, 07 Aug 2013 16:16:49 +0200 (2013-08-07) |
parents | af84ef787d93 |
children | d741f536f23a |
files | tests/run.py |
diffstat | 1 files changed, 8 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run.py +++ b/tests/run.py @@ -101,21 +101,24 @@ if __name__ == '__main__': args = [i.split('.py')[0].replace('-', '_') for i in args] + loader = unittest.TestLoader() + suite = unittest.TestSuite() + if not args: check = lambda x: options.comprehensive or not comprehensive(x) - mods = [m for (n, m) in sorted(all_tests.iteritems()) if check(m)] - suite = [m.suite() for m in mods] + suite.addTests(loader.loadTestsFromModule(m) + for (n, m) in sorted(all_tests.iteritems()) + if check(m)) else: - suite = [] for arg in args: if arg == 'test_util': continue elif arg not in all_tests: print >> sys.stderr, 'test module %s not available' % arg else: - suite.append(all_tests[arg].suite()) + suite.addTest(loader.loadTestsFromModule(all_tests[arg])) runner = unittest.TextTestRunner(**testargs) - result = runner.run(unittest.TestSuite(suite)) + result = runner.run(suite) if not result.wasSuccessful(): sys.exit(1)