def test_package(*package_names): tests = [] test_loader = TestLoader() for module_name, module in sys.modules.items(): for package_name in package_names: if module_name.startswith('{}.'.format(package_name)): module_tests = test_loader.loadTestsFromModule(module) module_tests = [t for t in module_tests if is_test_suite_loaded(t)] tests.extend(module_tests) test_result = TextTestRunner(failfast=True, resultclass=TimedTextTestResult).run(TestSuite(tests)) if not test_result.wasSuccessful(): raise Exception('test failed')
def test_package(*package_names): tests = [] test_loader = TestLoader() for module_name, module in sys.modules.items(): for package_name in package_names: if module_name.startswith('{}.'.format(package_name)): module_tests = test_loader.loadTestsFromModule(module) module_tests = [ t for t in module_tests if is_test_suite_loaded(t) ] tests.extend(module_tests) break test_result = TextTestRunner(failfast=True, resultclass=TimedTextTestResult).run( TestSuite(tests)) if not test_result.wasSuccessful(): raise Exception('test failed')