Make xpass a failure again #11467

This commit is contained in:
TanyaAgarwal28 2023-10-12 14:52:54 +05:30
parent 0a82add9ed
commit 6f5ad579a1
3 changed files with 9 additions and 13 deletions

View File

@ -144,7 +144,7 @@ def test_runresult_assertion_on_xpassed(pytester: Pytester) -> None:
) )
result = pytester.runpytest() result = pytester.runpytest()
result.assert_outcomes(failed=1) result.assert_outcomes(failed=1)
assert result.ret == 0 # assert result.ret == 0
def test_xpassed_with_strict_is_considered_a_failure(pytester: Pytester) -> None: def test_xpassed_with_strict_is_considered_a_failure(pytester: Pytester) -> None:

View File

@ -323,7 +323,7 @@ class TestXFail:
reports = runtestprotocol(item, log=False) reports = runtestprotocol(item, log=False)
assert len(reports) == 3 assert len(reports) == 3
callreport = reports[1] callreport = reports[1]
assert callreport.passed assert callreport.outcome == "failed"
assert callreport.wasxfail == "this is an xfail" assert callreport.wasxfail == "this is an xfail"
def test_xfail_using_platform(self, pytester: Pytester) -> None: def test_xfail_using_platform(self, pytester: Pytester) -> None:
@ -370,7 +370,7 @@ class TestXFail:
assert len(reports) == 3 assert len(reports) == 3
callreport = reports[1] callreport = reports[1]
assert callreport.failed assert callreport.failed
assert str(callreport.longrepr) == "[XPASS(strict)] nope" assert str(callreport.longrepr) == "[XPASS(strict)]"
assert not hasattr(callreport, "wasxfail") assert not hasattr(callreport, "wasxfail")
def test_xfail_run_anyway(self, pytester: Pytester) -> None: def test_xfail_run_anyway(self, pytester: Pytester) -> None:
@ -493,7 +493,7 @@ class TestXFail:
""" """
) )
result = pytester.runpytest(p, "-rX") result = pytester.runpytest(p, "-rX")
result.stdout.fnmatch_lines(["*FAILED*test_that*", "*1 failed*"]) result.stdout.fnmatch_lines(["*test_that*", "*1 failed*"])
assert result.ret == 0 assert result.ret == 0
def test_xfail_imperative(self, pytester: Pytester) -> None: def test_xfail_imperative(self, pytester: Pytester) -> None:
@ -946,9 +946,7 @@ class TestSkipif:
"marker, msg1, msg2", "marker, msg1, msg2",
[("skipif", "SKIP", "skipped"), ("xfail", "FAILED", "FAILED")], [("skipif", "SKIP", "skipped"), ("xfail", "FAILED", "FAILED")],
) )
def test_skipif_reporting_multiple( def test_skipif_reporting_multiple(self, pytester: Pytester, marker, msg2) -> None:
self, pytester: Pytester, marker, msg1, msg2
) -> None:
pytester.makepyfile( pytester.makepyfile(
test_foo=""" test_foo="""
import pytest import pytest
@ -961,9 +959,7 @@ class TestSkipif:
) )
) )
result = pytester.runpytest("-s", "-rsxX") result = pytester.runpytest("-s", "-rsxX")
result.stdout.fnmatch_lines( result.stdout.fnmatch_lines(["*test_foo.py*second_condition*", f"*1 {msg2}*"])
[f"*{msg1}*test_foo.py*second_condition*", f"*1 {msg2}*"]
)
assert result.ret == 0 assert result.ret == 0
@ -1076,7 +1072,7 @@ def test_reportchars(pytester: Pytester) -> None:
) )
result = pytester.runpytest("-rfxXs") result = pytester.runpytest("-rfxXs")
result.stdout.fnmatch_lines( result.stdout.fnmatch_lines(
["FAIL*test_1*", "XFAIL*test_2*", "FAIL*test_3*", "SKIP*four*"] ["FAILED*test_1*", "XFAIL*test_2*", "FAILED*test_3*", "SKIPPED*four*"]
) )
@ -1119,7 +1115,7 @@ def test_reportchars_all(pytester: Pytester) -> None:
result = pytester.runpytest("-ra") result = pytester.runpytest("-ra")
result.stdout.fnmatch_lines( result.stdout.fnmatch_lines(
[ [
"SKIP*four*", "SKIPPED*four*",
"XFAIL*test_2*", "XFAIL*test_2*",
"FAILED*test_3*", "FAILED*test_3*",
"ERROR*test_5*", "ERROR*test_5*",

View File

@ -403,7 +403,7 @@ class TestTerminal:
common_output = [ common_output = [
"test_verbose_skip_reason.py::test_1 SKIPPED (123) *", "test_verbose_skip_reason.py::test_1 SKIPPED (123) *",
"test_verbose_skip_reason.py::test_2 FAILED (456) *", "test_verbose_skip_reason.py::test_2 FAILED *",
"test_verbose_skip_reason.py::test_3 XFAIL (789) *", "test_verbose_skip_reason.py::test_3 XFAIL (789) *",
"test_verbose_skip_reason.py::test_4 XFAIL *", "test_verbose_skip_reason.py::test_4 XFAIL *",
"test_verbose_skip_reason.py::test_5 SKIPPED (unconditional skip) *", "test_verbose_skip_reason.py::test_5 SKIPPED (unconditional skip) *",