diff --git a/src/_pytest/skipping.py b/src/_pytest/skipping.py index 1046b9a83..173e3cdfd 100644 --- a/src/_pytest/skipping.py +++ b/src/_pytest/skipping.py @@ -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, ) diff --git a/testing/test_capture.py b/testing/test_capture.py index b6ea81613..7f311b5a7 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -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*") diff --git a/testing/test_skipping.py b/testing/test_skipping.py index e34bb0dd0..b7e448df3 100644 --- a/testing/test_skipping.py +++ b/testing/test_skipping.py @@ -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( diff --git a/testing/test_warnings.py b/testing/test_warnings.py index 96ecad6f6..47fefe684 100644 --- a/testing/test_warnings.py +++ b/testing/test_warnings.py @@ -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: