def run(self): self.setup_path() loader = ScanningLoader() test = loader.loadTestsFromName(self.test_suite) runner = unittest.TextTestRunner(verbosity=2) result = runner.run(test) sys.exit(not result.wasSuccessful())
def loadTestsFromNames(self, names, module=None): suite = ScanningLoader().loadTestsFromNames(names, module) for loader, name, ispkg in walk_packages( replify.__path__, replify.__name__ + '.' ): if ispkg: continue try: docsuite = DocTestSuite(name) except ValueError as err: if err.args[1] not in ['has no tests', 'has no docstrings']: raise continue suite.addTests(docsuite) for dirpath, dirnames, filenames in os.walk(DOC_PATH): for i, d in reverse_iter(dirnames): if d.startswith('_'): del dirnames[i] for f in filenames: if not f.endswith('.rst'): continue docsuite = DocFileSuite( os.path.join(dirpath, f), module_relative=False) suite.addTests(docsuite) return suite
def loadTestsFromNames(self, names, module=None): suite = ScanningLoader().loadTestsFromNames(names, module) for loader, name, ispkg in walk_packages(potpy.__path__, potpy.__name__ + '.'): if ispkg: continue try: docsuite = DocTestSuite(name) except ValueError, err: if err.args[1] != 'has no tests': raise continue suite.addTests(docsuite)
def loadTestsFromModule(self, module): """ Support test module and function name based filtering """ testsuites = ScanningLoader.loadTestsFromModule(self, module) test_filter = getattr(__builtin__,'__test_filter') res = testsuites if test_filter['module'] is not None: name = module.__name__ if name in test_filter['allowmods']: # a parent name space pass elif re.search(test_filter['module'], name): if test_filter['function'] is not None: res = filter_testsuites(testsuites) # add parents (and module itself) pms = name.split('.') for pm_idx in range(len(pms)): pm = '.'.join(pms[:pm_idx]) if not pm in test_filter['allowmods']: test_filter['allowmods'].append(pm) else: res = type(testsuites)() return res
def collect(self): for spec in self.spec_list: if ":" in spec: modname, funcname = spec.split(":") mod = __import__(modname, None, None, ["doc"]) func = getattr(mod, funcname) suites = func() else: mod = __import__(spec, None, None, ["doc"]) from setuptools.command.test import ScanningLoader scanningLoader = ScanningLoader() suites = scanningLoader.loadTestsFromModule(mod) for item in suites: if isinstance(item, unittest.TestSuite): yield UnitTestSuite("", parent=self, suite=item)
def loadTestsFromNames(self, names, module=None): suite = ScanningLoader().loadTestsFromNames(names, module) for loader, name, ispkg in walk_packages(replify.__path__, replify.__name__ + '.'): if ispkg: continue try: docsuite = DocTestSuite(name) except ValueError as err: if err.args[1] not in ['has no tests', 'has no docstrings']: raise continue suite.addTests(docsuite) for dirpath, dirnames, filenames in os.walk(DOC_PATH): for i, d in reverse_iter(dirnames): if d.startswith('_'): del dirnames[i] for f in filenames: if not f.endswith('.rst'): continue docsuite = DocFileSuite(os.path.join(dirpath, f), module_relative=False) suite.addTests(docsuite) return suite
def loadTestsFromNames(self, suitename, module=None): names = suitename[0].split(',') return ScanningLoader().loadTestsFromNames(names, module)
def loadTestsFromModule(self, module): return skipLayers(ScanningLoader.loadTestsFromModule(self, module))
def loadTestsFromNames(self, *args, **kwargs): s = ScanningLoader.loadTestsFromNames(self, *args, **kwargs) wrapper = TestSuite() wrapper.addTests(s) return wrapper
def loadTestsFromNames(self, testNames, module): return skipLayers( ScanningLoader.loadTestsFromNames(self, testNames, module))
# Top-level interface to run the Glasgow tests. import unittest from setuptools.command.test import ScanningLoader if __name__ == "__main__": unittest.main(module="glasgow", testLoader=ScanningLoader())