Skip to content

Commit

Permalink
[test] The test that asserts compatibility with pytest.mark.xfail rep…
Browse files Browse the repository at this point in the history
…orts success rather than "xfailed" when the test succeeded.

Signed-off-by: Michael Seifert <[email protected]>
  • Loading branch information
seifertm committed Jul 12, 2023
1 parent df88119 commit 7fa36f2
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions tests/test_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from textwrap import dedent

import pytest
from pytest import Pytester

import pytest_asyncio.plugin

Expand All @@ -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
Expand Down

0 comments on commit 7fa36f2

Please sign in to comment.