Esempio n. 1
0
def main(argv, prepare_args=prepare_argv, find_tests=find_tests):
    """CLI entry point to adapt a test run to parallel testing."""
    child_args = prepare_argv(argv)
    test_ids = find_tests(argv)

    # We could create a proxy object per test id if desired in future)
    def parallelise_tests(suite):
        test_ids = list(suite)[0]._test_ids
        count = concurrency()
        partitions = partition_tests(test_ids, count)
        return [
            ListTestCase(partition, child_args) for partition in partitions
        ]

    suite = ConcurrentTestSuite(ListTestCase(test_ids, None),
                                parallelise_tests)
    if '--subunit' in argv:
        runner = SubunitTestRunner(sys.stdout)
        result = runner.run(suite)
    else:
        stream = unicode_output_stream(sys.stdout)
        result = TextTestResult(stream)
        result.startTestRun()
        try:
            suite.run(result)
        finally:
            result.stopTestRun()
    if result.wasSuccessful():
        return 0
    return -1
Esempio n. 2
0
 def run(self, test):
     "Run the given test case or test suite."
     result = TextTestResult(unicode_output_stream(self.stdout))
     result.startTestRun()
     try:
         return test.run(result)
     finally:
         result.stopTestRun()
 def _run(self, stream, test):
     """Run the test, the same as in testtools.run but not to stdout"""
     result = TextTestResult(stream)
     result.startTestRun()
     try:
         return test.run(result)
     finally:
         result.stopTestRun()
 def test__init_sets_stream(self):
     result = TextTestResult("fp")
     self.assertEqual("fp", result.stream)
 def setUp(self):
     super(TestTextTestResult, self).setUp()
     self.result = TextTestResult(StringIO())
 def makeResult(self):
     return TextTestResult(StringIO())
Esempio n. 7
0
def _construct_text(**kwargs):
    stream = kwargs.pop('stream')
    failfast = kwargs.pop('failfast')
    _raise_on_unknown_kwargs(kwargs)
    return LoggedTestResultDecorator(TextTestResult(stream, failfast))