Skip to content

Commit

Permalink
[refactor] Extracted test for pytest.skip into a separate test module.
Browse files Browse the repository at this point in the history
This prevents unrelated tests from aggregating in test_simple.py.

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
  • Loading branch information
seifertm committed Dec 3, 2023
1 parent 0b34e8e commit 176d558
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 35 deletions.
38 changes: 38 additions & 0 deletions tests/test_pytest_skip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from textwrap import dedent

from pytest import Pytester


def test_asyncio_marker_compatibility_with_skip(pytester: Pytester):
pytester.makepyfile(
dedent(
"""\
import pytest
pytest_plugins = "pytest_asyncio"
@pytest.mark.asyncio
async def test_no_warning_on_skip():
pytest.skip("Test a skip error inside asyncio")
"""
)
)
result = pytester.runpytest("--asyncio-mode=strict")
result.assert_outcomes(skipped=1)


def test_asyncio_auto_mode_compatibility_with_skip(pytester: Pytester):
pytester.makepyfile(
dedent(
"""\
import pytest
pytest_plugins = "pytest_asyncio"
async def test_no_warning_on_skip():
pytest.skip("Test a skip error inside asyncio")
"""
)
)
result = pytester.runpytest("--asyncio-mode=auto")
result.assert_outcomes(skipped=1)
35 changes: 0 additions & 35 deletions tests/test_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,41 +100,6 @@ async def test_event_loop_before_fixture(self, loop):
assert await loop.run_in_executor(None, self.foo) == 1


def test_asyncio_marker_compatibility_with_skip(pytester: Pytester):
pytester.makepyfile(
dedent(
"""\
import pytest
pytest_plugins = "pytest_asyncio"
@pytest.mark.asyncio
async def test_no_warning_on_skip():
pytest.skip("Test a skip error inside asyncio")
"""
)
)
result = pytester.runpytest("--asyncio-mode=strict")
result.assert_outcomes(skipped=1)


def test_asyncio_auto_mode_compatibility_with_skip(pytester: Pytester):
pytester.makepyfile(
dedent(
"""\
import pytest
pytest_plugins = "pytest_asyncio"
async def test_no_warning_on_skip():
pytest.skip("Test a skip error inside asyncio")
"""
)
)
result = pytester.runpytest("--asyncio-mode=auto")
result.assert_outcomes(skipped=1)


def test_invalid_asyncio_mode(testdir):
result = testdir.runpytest("-o", "asyncio_mode=True")
result.stderr.no_fnmatch_line("INTERNALERROR> *")
Expand Down

0 comments on commit 176d558

Please sign in to comment.