Beispiel #1
0
def test_report_detailed_with_filter(tmpdir, cmdout):
    run_suite_class(mysuite, tmpdir=tmpdir, backends=[JsonBackend()])

    assert main(["report", tmpdir.strpath, "--failed"]) == 0

    cmdout.dump()
    cmdout.assert_substrs_in_line(0, ["My Test 1"])
    cmdout.assert_substrs_in_line(1, ["mysuite.mytest1"])
    cmdout.assert_substrs_in_line(3, ["My Test 1"])
    cmdout.assert_substrs_in_line(5, ["ERROR", "failure"])
    cmdout.assert_lines_nb(9)
Beispiel #2
0
def test_report_detailed_with_arguments(tmpdir, cmdout):
    run_suite_class(mysuite, tmpdir=tmpdir, backends=[JsonBackend()])

    assert main(["report", tmpdir.strpath, "--explicit", "--max-width=80"]) == 0

    cmdout.dump()
    cmdout.assert_substrs_in_line(0, ["FAILED: My Test 1"])
    cmdout.assert_substrs_in_line(1, ["mysuite.mytest1"])
    cmdout.assert_substrs_in_line(3, ["My Test 1"])
    cmdout.assert_substrs_in_line(5, ["ERROR", "failure"])
    cmdout.assert_substrs_in_line(8, ["My Test 2"])
    cmdout.assert_substrs_in_line(9, ["mysuite.mytest2"])
    cmdout.assert_substrs_in_line(10, ["n/a"])
    cmdout.assert_lines_nb(13)
Beispiel #3
0
def test_run_filter_from_report(tmpdir):
    @lcc.suite("mysuite")
    class mysuite:
        @lcc.test("mytest")
        def mytest(self):
            pass

    suite = load_suite_from_class(mysuite)

    run_suite(suite, backends=[JsonBackend()], tmpdir=tmpdir)

    cli_parser = argparse.ArgumentParser()
    add_run_filter_cli_args(cli_parser)
    cli_args = cli_parser.parse_args(args=["--from-report", tmpdir.strpath])
    filtr = make_report_filter(cli_args)
    assert filtr.match_test(suite.get_tests()[0])
Beispiel #4
0
def test_report_with_filter(tmpdir, cmdout):
    run_suite_class(mysuite, tmpdir=tmpdir, backends=[JsonBackend()])

    assert main(["report", tmpdir.strpath, "--passed", "--short"]) == 0
    assert_run_output(cmdout, "mysuite", successful_tests=["mytest2"])
Beispiel #5
0
def test_report_from_file(tmpdir, cmdout):
    backend = JsonBackend()
    run_suite_class(mysuite, tmpdir=tmpdir, backends=[backend])

    assert main(["report", osp.join(tmpdir.strpath, backend.get_report_filename()), "--short"]) == 0
    assert_run_output(cmdout, "mysuite", successful_tests=["mytest2"], failed_tests=["mytest1"])
Beispiel #6
0
def test_report_from_dir(tmpdir, cmdout):
    run_suite_class(mysuite, tmpdir=tmpdir, backends=[JsonBackend()])

    assert main(["report", tmpdir.strpath, "--short"]) == 0
    assert_run_output(cmdout, "mysuite", successful_tests=["mytest2"], failed_tests=["mytest1"])
Beispiel #7
0
def backend():
    return JsonBackend()