Example #1
0
 def assertSuitesEqual(self, test1, names):
     loader = TestLoader()
     names1 = testNames(test1)
     names2 = testNames(TestSuite(map(loader.loadByName, names)))
     names1.sort()
     names2.sort()
     self.assertEqual(names1, names2)
Example #2
0
def runTests():
    """
    Run all of mimics tests.
    """
    loader = TestLoader()
    suite = loader.loadPackage(test)
    passFail = not TrialRunner(VerboseTextReporter).run(suite).wasSuccessful()
    sys.exit(passFail)
Example #3
0
def _load_tests(name):
    """
    Find all the tests under ``name``.

    :param str name: The fully-qualified Python name of an object.
    :return: A ``TestSuite`` or ``TestCase`` containing all the tests.
    """
    loader = TestLoader()
    return loader.loadByName(name, recurse=True)
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)
Example #5
0
def get_tests_for(python_name):
    """
    Find all tests for the given ``python_name``.

    :param python_name: Either directory in ``REPOSITORY`` or a Python FQPN
        importable from ``REPOSITORY``.
    :return: PSet of test names.
    """
    def _extract_ids(t):
        if isinstance(t, TestSuite):
            result = pset()
            for sub_tests in t:
                result = result | _extract_ids(sub_tests)
            return result
        else:
            return pset([t.id()])

    loader = TestLoader()
    tests = loader.loadByName(python_name, recurse=True)
    return _extract_ids(tests)
Example #6
0
    def setUp(self):
        self.loader = TestLoader()
        try:
            from twisted.trial.unittest import TestVisitor

            class MockVisitor(TestVisitor):
                def __init__(self):
                    self.calls = []

                def visitCase(self, testCase):
                    self.calls.append(("case", testCase))

                def visitSuite(self, testModule):
                    self.calls.append(("suite", testModule))

                def visitSuiteAfter(self, testModule):
                    self.calls.append(("suite_after", testModule))

            self.mock_visitor = MockVisitor
        except ImportError:
            pass
Example #7
0
 def setUp(self):
     self.config = trial.Options()
     self.loader = TestLoader()
Example #8
0
 def __init__(self, forceGarbageCollection=False):
     self._loader = TestLoader()
     self._result = WorkerReporter(self)
     self._forceGarbageCollection = forceGarbageCollection
                            data_suffix=True,
                            config_file=False,
                            branch=True,
                            source=['ipv8'],
                            include=['*'],
                            omit="ipv8/ipv8.py")
    cov.exclude('pass')
    cov.start()

    for line in lines:
        print "Measuring coverage for", line

        output_stream = StringIO()
        formatted_line = line.replace('/', '.').replace('.py:', '.')

        suite = TestLoader().loadTestsFromName(formatted_line)
        reporter = VerboseTextReporter(stream=output_stream)
        reporter.failfast = True
        suite.run(reporter)

        assert len(reporter.errors) == 0,\
            "ERROR: UNIT TESTS FAILED, PLEASE FIX BEFORE RUNNING COVERAGE:\n%s\n%s" % (output_stream.getvalue(), ''.join([repr(error) for error in reporter.errors]))
        output_stream.close()

    cov.stop()
    print "Generating HTML report"
    cov.html_report(directory='coverage', omit="ipv8/keyvault/libnacl/*")
    cov.erase()

clean_directory()
Example #10
0
def testSuite():
    loader = TestLoader()
    return TestSuite(
        list(
            loader.loadModule(namedModule(module))
            for module in PORTED_TEST_MODULES))
Example #11
0
def runtests(root_dir='pyofwave'):
    runner = TrialRunner(TreeReporter)
    loader = TestLoader()
    failures = runner.run(loader.loadByName(root_dir, recurse=True))
    sys.exit(failures)