예제 #1
0
def runTests():
    """
    Run all of mimics tests.
    """
    loader = TestLoader()
    suite = loader.loadPackage(test)
    passFail = not TrialRunner(VerboseTextReporter).run(suite).wasSuccessful()
    sys.exit(passFail)
예제 #2
0
def run():
    loader = TestLoader()
    suite = loader.loadPackage(lbrynet.tests, True)
    runner = TrialRunner(AndroidTestReporter)
    runner.stream = str_stream
    passFail = not runner.run(suite).wasSuccessful()

    print str_stream.getvalue()
    sys.exit(passFail)
예제 #3
0
    def run_suite(self, suite=None, **kwargs):
        non_server_result = super(MagicicadaRunner,
                                  self).run_suite(self.non_server_suite,
                                                  **kwargs)
        if not non_server_result.wasSuccessful():
            return non_server_result

        server_result = TrialRunner(reporterFactory=self.factory,
                                    realTimeErrors=True,
                                    workingDirectory=WORKING_DIR).run(
                                        self.server_suite)
        return server_result
예제 #4
0
 def _make_runner(self, config, stream):
     # Based on twisted.scripts.trial._makeRunner
     mode = None
     if config['debug']:
         mode = TrialRunner.DEBUG
     if config['dry-run']:
         mode = TrialRunner.DRY_RUN
     return TrialRunner(config['reporter'],
                        mode=mode,
                        stream=stream,
                        profile=config['profile'],
                        logfile=config['logfile'],
                        tracebackFormat=config['tbformat'],
                        realTimeErrors=config['rterrors'],
                        uncleanWarnings=config['unclean-warnings'],
                        workingDirectory=config['temp-directory'],
                        forceGarbageCollection=config['force-gc'])
예제 #5
0
def runtests(root_dir='pyofwave'):
    runner = TrialRunner(TreeReporter)
    loader = TestLoader()
    failures = runner.run(loader.loadByName(root_dir, recurse=True))
    sys.exit(failures)
예제 #6
0
def test_with_trial(options, topdir, testdirs, testpaths):
    """The main testing entry point."""
    # parse arguments

    # Ensure that the database watcher is installed early, so that
    # unexpected database access can be blocked.
    from backends.testing.resources import DatabaseResource
    watcher = DatabaseResource.get_watcher()
    watcher.enable('account')

    reporter_decorators = []
    if options.one:
        reporter_decorators.append(StopOnFailureDecorator)
    if options.logs_on_failure:
        reporter_decorators.append(LogsOnFailureDecorator)

    def factory(*args, **kwargs):
        """Custom factory tha apply the decorators to the TreeReporter"""
        if options.subunit:
            return SubunitReporter(*args, **kwargs)
        else:
            result = TreeReporter(*args, **kwargs)
            for decorator in reporter_decorators:
                result = decorator(result)
            return result

    reporterFactory = factory
    runner = TrialRunner(reporterFactory=reporterFactory,
                         realTimeErrors=True,
                         workingDirectory=WORKING_DIR)

    suite = UnsortedOptimisingTestSuite()
    suite.adsorbSuite(collect_tests(topdir, testdirs, testpaths))

    if options.test:
        old_suite = suite
        suite = UnsortedOptimisingTestSuite()
        pattern = re.compile('.*%s.*' % options.test)
        for test in iter(old_suite):
            if pattern.match(test.id()):
                suite.addTest(test)

    if options.ignore:
        old_suite = suite
        suite = UnsortedOptimisingTestSuite()
        pattern = re.compile('.*%s.*' % options.ignore)
        for test in iter(old_suite):
            if not pattern.match(test.id()):
                suite.addTest(test)

    if options.loops > 1:
        # we could loop the .run() call, but creating a suite that contains
        # duplicate tests is more efficient and more likely to expose
        # test-to-test issues. Plus, the testrun summary reports are nicer
        # this way --gafton
        old_suite = suite
        suite = UnsortedOptimisingTestSuite()
        for x in xrange(options.loops):
            suite.addTest(old_suite)

    if options.debug:
        DelayedCall.debug = True

    watcher.disable('account')
    if options.coverage:
        tracer = trace.Trace(trace=False, count=True)
        tracer.runctx('runner.run(suite)', globals=globals(), locals=vars())
        r = tracer.results()
        if not os.path.exists(COVERAGE_DIR):
            os.mkdir(COVERAGE_DIR)
        r.write_results(show_missing=True, summary=True, coverdir=COVERAGE_DIR)
    else:
        result = runner.run(suite)
        return not result.wasSuccessful()