def test_fixtures_empty_project(notest_project, cmdout): assert run_main(["fixtures"]) == 0 cmdout.assert_lines_match(".*session_prerun.*:.*none.*") cmdout.assert_lines_match(".*session.*:.*none.*") cmdout.assert_lines_match(".*suite.*:.*none.*") cmdout.assert_lines_match(".*test.*:.*none.*")
def test_fixtures(project, cmdout): assert run_main(["fixtures"]) == 0 cmdout.assert_lines_match(".+qux.+ 1 .+ 0 .+") cmdout.assert_lines_match(".+foo.+ 1 .+ 2 .+") cmdout.assert_lines_match(".+bar.+foo.+ 1 .+ 1 .+") cmdout.assert_lines_match(".+baz.+bar.+ 0 .+ 2 .+")
def test_stats_with_filter(project, cmdout): assert run_main(["stats", "mysuite.mytest1"]) == 0 # tags: cmdout.assert_lines_match(".+suite_tag.+ 1 .+ 100%") cmdout.assert_lines_match(".+test_tag.+ 1 .+ 100%") # properties: cmdout.assert_lines_match(".+suite_prop.+suite_prop_value.+ 1 .+ 100%") cmdout.assert_lines_match(".+test_prop.+test_prop_value1.+ 1 .+ 100%") # links: cmdout.assert_lines_match(".+#1234.+http://bug.tra.cker/1234.+ 1 .+ 100%") # totals: cmdout.assert_lines_match(".+1.+tests.+1.+suites.*")
def test_stats(project, cmdout): assert run_main(["stats"]) == 0 # tags: cmdout.assert_lines_match(".+suite_tag.+ 2 .+ 100%") cmdout.assert_lines_match(".+test_tag.+ 1 .+ 50%") cmdout.assert_lines_match(".+foo.+ 1 .+ 50%") # properties: cmdout.assert_lines_match(".+suite_prop.+suite_prop_value.+ 2 .+ 100%") cmdout.assert_lines_match(".+test_prop.+test_prop_value1.+ 1 .+ 50%") cmdout.assert_lines_match(".+test_prop.+test_prop_value2.+ 1 .+ 50%") # links: cmdout.assert_lines_match(".+#1234.+http://bug.tra.cker/1234.+ 2 .+ 100%") cmdout.assert_lines_match(".+-.+http://bug.tra.cker/1235.+ 1 .+ 50%") # totals: cmdout.assert_lines_match(".+2.+tests.+1.+suites.*")
def test_bootstrap(tmpdir): project_dir = tmpdir.join("myproj").strpath assert run_main(["bootstrap", project_dir]) == 0 project = load_project_from_dir(project_dir) assert project.get_suites() == []
def test_bootstrap_existing_directory(tmpdir): out = run_main(["bootstrap", tmpdir.strpath]) assert out.startswith("Cannot create project")
def test_version_as_arg(cmdout): try: run_main(["-v"]) except SystemExit: pass cmdout.assert_substrs_in_line(0, [__version__])
def test_version_as_cmd(cmdout): assert run_main(["version"]) == 0 cmdout.assert_substrs_in_line(0, [__version__])
def test_no_cmd(cmdout): try: run_main([]) except SystemExit: pass cmdout.assert_substrs_in_line(0, ["usage:"], on_stderr=True)
def test_exit_error_on_failure_failing_suite(failing_project): assert run_main(["run", "--exit-error-on-failure"]) == 1
def test_exit_error_on_failure_successful_suite(successful_project): assert run_main(["run", "--exit-error-on-failure"]) == 0
def test_stop_on_failure(project, cmdout): assert run_main(["run", "--stop-on-failure"]) == 0 assert_run_output(cmdout, "mysuite", failed_tests=["mytest1"], skipped_tests=["mytest2"])
def test_project_with_fixtures(project_with_fixtures, cmdout): assert run_main(["run", "mysuite.mytest1"]) == 0 assert_run_output(cmdout, "mysuite", successful_tests=["mytest1"])
def test_run_with_filter(project, cmdout): assert run_main(["run", "mysuite.mytest1"]) == 0 assert_run_output(cmdout, "mysuite", failed_tests=["mytest1"])
def test_run(project, cmdout): assert run_main(["run"]) == 0 assert_run_output(cmdout, "mysuite", successful_tests=["mytest2"], failed_tests=["mytest1"])
def test_stats_empty_project(empty_project, cmdout): assert "No test is defined" in run_main(["stats"])