# HG changeset patch # User Dan Villiom Podlaski Christiansen # Date 1375885009 -7200 # Node ID 69a9fb45cad5458c192f76045eb5934433e7aeec # Parent af84ef787d93e200a25fb1a438c49f4e51b0bd45 tests: consolidate all test-loading into the test runner diff --git a/tests/run.py b/tests/run.py --- 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)