From 7fa36f24f406ea65b4281444efdd3ef4a4e9f353 Mon Sep 17 00:00:00 2001 From: Michael Seifert Date: Wed, 12 Jul 2023 10:56:56 +0200 Subject: [PATCH] [test] The test that asserts compatibility with pytest.mark.xfail reports success rather than "xfailed" when the test succeeded. Signed-off-by: Michael Seifert --- tests/test_simple.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/tests/test_simple.py b/tests/test_simple.py index b91afd4a..1cf71b7a 100644 --- a/tests/test_simple.py +++ b/tests/test_simple.py @@ -3,6 +3,7 @@ from textwrap import dedent import pytest +from pytest import Pytester import pytest_asyncio.plugin @@ -25,10 +26,23 @@ async def test_asyncio_marker(): await asyncio.sleep(0) -@pytest.mark.xfail(reason="need a failure", strict=True) -@pytest.mark.asyncio -async def test_asyncio_marker_fail(): - raise AssertionError +def test_asyncio_marker_compatibility_with_xfail(pytester: Pytester): + pytester.makepyfile( + dedent( + """\ + import pytest + + pytest_plugins = "pytest_asyncio" + + @pytest.mark.xfail(reason="need a failure", strict=True) + @pytest.mark.asyncio + async def test_asyncio_marker_fail(): + raise AssertionError + """ + ) + ) + result = pytester.runpytest("--asyncio-mode=strict") + result.assert_outcomes(xfailed=1) @pytest.mark.asyncio