Skip to content

Commit 7fa36f2

Browse files
committed
[test] The test that asserts compatibility with pytest.mark.xfail reports success rather than "xfailed" when the test succeeded.
Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
1 parent df88119 commit 7fa36f2

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

tests/test_simple.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from textwrap import dedent
44

55
import pytest
6+
from pytest import Pytester
67

78
import pytest_asyncio.plugin
89

@@ -25,10 +26,23 @@ async def test_asyncio_marker():
2526
await asyncio.sleep(0)
2627

2728

28-
@pytest.mark.xfail(reason="need a failure", strict=True)
29-
@pytest.mark.asyncio
30-
async def test_asyncio_marker_fail():
31-
raise AssertionError
29+
def test_asyncio_marker_compatibility_with_xfail(pytester: Pytester):
30+
pytester.makepyfile(
31+
dedent(
32+
"""\
33+
import pytest
34+
35+
pytest_plugins = "pytest_asyncio"
36+
37+
@pytest.mark.xfail(reason="need a failure", strict=True)
38+
@pytest.mark.asyncio
39+
async def test_asyncio_marker_fail():
40+
raise AssertionError
41+
"""
42+
)
43+
)
44+
result = pytester.runpytest("--asyncio-mode=strict")
45+
result.assert_outcomes(xfailed=1)
3246

3347

3448
@pytest.mark.asyncio

0 commit comments

Comments
 (0)