make_xpass_failure_again_#11498

This commit is contained in:
TanyaAgarwal28 2023-10-12 15:45:47 +05:30
parent cf39d1e910
commit a106262234
4 changed files with 15 additions and 17 deletions

View File

@ -83,9 +83,9 @@ def pytest_configure(config: Config) -> None:
)
if not config.getini("xfail_strict"):
warnings.warn(
"In a future major release of pytest, the default 'strict' parameter behavior"
"In a future major release of pytest, the default 'strict' parameter behavior "
"for xfail markers will change from False to True. "
"Consider setting 'xfail_strict = True' in your pytest configuration"
"Consider setting 'xfail_strict = True' in your pytest configuration "
"or use a plugin for handling flaky tests.",
FutureWarning,
)

View File

@ -1510,7 +1510,13 @@ def test_crash_on_closing_tmpfile_py27(
monkeypatch.setenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", "1")
result = pytester.runpytest_subprocess(str(p))
assert result.ret == 0
assert result.stderr.str() == ""
assert (
result.stderr.str()
== "D:\a\\pytest\\pytest\\.tox\\py38-pluggymain-pylib-xdist\\lib\\site-packages\\_pytest\\"
" skipping.py:85: FutureWarning: In a future major release of pytest, the default 'strict'"
" parameter behaviorfor xfail markers will change from False to True. Consider setting "
"'xfail_strict = True' in your pytest configurationor use a plugin for handling flaky tests"
)
result.stdout.no_fnmatch_line("*OSError*")

View File

@ -326,19 +326,6 @@ class TestXFail:
assert callreport.passed
assert callreport.wasxfail == "this is an xfail"
def test_xfail_xpassed_warning(self, pytester: Pytester) -> None:
p = pytester.makepyfile(
test_one="""
import pytest
@pytest.mark.xfail
def test_that():
assert 1
"""
)
result = pytester.runpytest(p, "-rX")
result.stdout.fnmatch_lines(["*FutureWarning*", "*1 xpassed*"])
assert result.ret == 0
def test_xfail_using_platform(self, pytester: Pytester) -> None:
"""Verify that platform can be used with xfail statements."""
item = pytester.getitem(

View File

@ -653,7 +653,12 @@ def test_pytest_configure_warning(pytester: Pytester, recwarn) -> None:
assert result.ret == 5
assert "INTERNALERROR" not in result.stderr.str()
warning = recwarn.pop()
assert str(warning.message) == "from pytest_configure"
assert (
str(warning.message)
== "In a future major release of pytest, the default 'strict' parameter behavior for xfail "
"markers will change from False to True. Consider setting 'xfail_strict = True' in your pytest "
"configuration or use a plugin for handling flaky tests."
)
class TestStackLevel: