Esempio n. 1
0
    def test_output_tests(self):
        class Test:
            def __init__(self, i):
                self.i = i

            def id(self):
                return self.i

        tests = [Test('a'), Test('b'), Test('foo')]
        expected = "a\nb\nfoo\n"
        with io.StringIO() as f:
            output.output_tests(tests, f)
            actual = f.getvalue()
            self.assertEqual(expected, actual)
Esempio n. 2
0
            return repo.get_latest_run().get_id()

        output_result = results.CLITestResult(_get_id, sys.stdout, None)
        summary_result = output_result.get_summary()
        return output_result, summary_result


def run(arguments):
    args = arguments[0]
    repo = util.get_repo_open(args.repo_type, args.repo_url)
    run = repo.get_failing()
    if args.subunit:
        return _show_subunit(run)
    case = run.get_test()
    failed = False
    result, summary = _make_result(repo, list_tests=args.list)
    result.startTestRun()
    try:
        case.run(result)
    finally:
        result.stopTestRun()
    failed = not summary.wasSuccessful()
    if failed:
        result = 1
    else:
        result = 0
    if args.list:
        failing_tests = [test for test, _ in summary.errors + summary.failures]
        output.output_tests(failing_tests)
    return result
Esempio n. 3
0
    :return return_code: The exit code for the command. 0 for success and > 0
        for failures.
    :rtype: int
    """
    if repo_type not in ['file', 'sql']:
        stdout.write('Repository type %s is not a type' % repo_type)
        return 1

    repo = util.get_repo_open(repo_type, repo_url)
    run = repo.get_failing()
    if subunit:
        return _show_subunit(run)
    case = run.get_test()
    failed = False
    result, summary = _make_result(repo, list_tests=list_tests)
    result.startTestRun()
    try:
        case.run(result)
    finally:
        result.stopTestRun()
    failed = not results.wasSuccessful(summary)
    if failed:
        result = 1
    else:
        result = 0
    if list_tests:
        failing_tests = [test for test, _ in summary.errors + summary.failures]
        output.output_tests(failing_tests, output=stdout)
    return result