def call_trial(*tests, **kwargs): import spyne.test try: import twisted.scripts.trial except ImportError: return 1 global _ctr _ctr += 1 file_name = 'test_result.%d.subunit' % _ctr with SubUnitTee(file_name): tests_dir = os.path.dirname(spyne.test.__file__) sys.argv = ['trial', '--reporter=subunit'] sys.argv.extend(chain(*[glob(join(tests_dir, test)) for test in tests])) from twisted.scripts.trial import Options from twisted.scripts.trial import _makeRunner from twisted.scripts.trial import _getSuite config = Options() config.parseOptions() trialRunner = _makeRunner(config) suite = _getSuite(config) test_result = trialRunner.run(suite) try: subunit2junitxml(_ctr) except Exception as e: # this is not super important. print(e) return int(not test_result.wasSuccessful())
def call_trial(*tests): import spyne.test from glob import glob from itertools import chain global _ctr _ctr += 1 file_name = 'test_result.%d.subunit' % _ctr with SubUnitTee(file_name): tests_dir = os.path.dirname(spyne.test.__file__) sys.argv = ['trial', '--reporter=subunit'] sys.argv.extend(chain(*[glob(join(tests_dir, test)) for test in tests])) from twisted.scripts.trial import Options from twisted.scripts.trial import _makeRunner from twisted.scripts.trial import _getSuite config = Options() config.parseOptions() trialRunner = _makeRunner(config) suite = _getSuite(config) test_result = trialRunner.run(suite) try: subunit2junitxml(_ctr) except Exception as e: # this is not super important. print e return int(not test_result.wasSuccessful())
def run(): config = Options() config.parseOptions() trialRunner = _makeRunner(config) suite = _getSuite(config) test_result = trialRunner.run(suite) return int(not test_result.wasSuccessful())
def _tests_func(self, tests, worker_index): if not isinstance(tests, (list, set)): tests = [tests] args = ['-e'] args.extend(tests) config = Options() config.parseOptions(args) stream = BufferWritesDevice() runner = self._make_runner(config=config, stream=stream) suite = _getSuite(config) result = setup_test_db(worker_index, None, runner.run, suite) result = TestResult().from_trial_result(result) return result
class CustomSuite(unittest.TestSuite): def __init__(self, tests=()): stripped = [] for test in tests: if isinstance(test, CustomSuite): stripped.append(test) elif any(member[0].startswith('test_') for member in inspect.getmembers(test)): stripped.append(test) super(CustomSuite, self).__init__(tests=stripped) if __name__ == "__main__": # We have to regen the plugins cache to be able to install # alternative reactors. Regen utility should be run in a separate # interpreter because reactors cannot be installed twice or unloaded. subprocess.call(["python", "regen_plugins_cache.py"]) config = Options() config.parseOptions() config['tbformat'] = 'verbose' config['exitfirst'] = True _initialDebugSetup(config) trialRunner = _makeRunner(config) test_loader = TestLoader() test_loader.suiteClass = CustomSuite test_suite = test_loader.discover(abspath(join('.', 'ipv8', 'test')), top_level_dir=abspath('.')) test_result = trialRunner.run(test_suite)