def main(): test_classes = set() for name, obj in inspect.getmembers(sys.modules[__name__]): if inspect.isclass(obj): if obj.__module__ == '__main__' and name.startswith('Test'): test_classes.add(obj) loader = unittest.TestLoader() suite = [] for test_class in test_classes: suite.append(loader.loadTestsFromTestCase(test_class)) runner = unittest.TextTestRunner(verbosity=VERBOSITY) result = runner.run(unittest.TestSuite(unittest.TestSuite(suite))) success = result.wasSuccessful() sys.exit(0 if success else 1)
def main(): testmodules = [ os.path.splitext(x)[0] for x in os.listdir(HERE) if x.endswith('.py') and x.startswith('test_') ] configure_logging() remove_test_files() suite = unittest.TestSuite() for t in testmodules: suite.addTest(unittest.defaultTestLoader.loadTestsFromName(t)) result = unittest.TextTestRunner(verbosity=VERBOSITY).run(suite) return result.wasSuccessful()
def get_suite(name=None): suite = unittest.TestSuite() if name is None: testmods = [ os.path.splitext(x)[0] for x in os.listdir(HERE) if x.endswith('.py') and x.startswith('test_') ] for tm in testmods: # ...so that the full test paths are printed on screen tm = "pyftpdlib.test.%s" % tm suite.addTest(unittest.defaultTestLoader.loadTestsFromName(tm)) else: name = os.path.splitext(os.path.basename(name))[0] suite.addTest(unittest.defaultTestLoader.loadTestsFromName(name)) return suite