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 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