Skip to content

Commit 176d558

Browse files
committed
[refactor] Extracted test for pytest.skip into a separate test module.
This prevents unrelated tests from aggregating in test_simple.py. Signed-off-by: Michael Seifert <[email protected]>
1 parent 0b34e8e commit 176d558

File tree

2 files changed

+38
-35
lines changed

2 files changed

+38
-35
lines changed

tests/test_pytest_skip.py

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from textwrap import dedent
2+
3+
from pytest import Pytester
4+
5+
6+
def test_asyncio_marker_compatibility_with_skip(pytester: Pytester):
7+
pytester.makepyfile(
8+
dedent(
9+
"""\
10+
import pytest
11+
12+
pytest_plugins = "pytest_asyncio"
13+
14+
@pytest.mark.asyncio
15+
async def test_no_warning_on_skip():
16+
pytest.skip("Test a skip error inside asyncio")
17+
"""
18+
)
19+
)
20+
result = pytester.runpytest("--asyncio-mode=strict")
21+
result.assert_outcomes(skipped=1)
22+
23+
24+
def test_asyncio_auto_mode_compatibility_with_skip(pytester: Pytester):
25+
pytester.makepyfile(
26+
dedent(
27+
"""\
28+
import pytest
29+
30+
pytest_plugins = "pytest_asyncio"
31+
32+
async def test_no_warning_on_skip():
33+
pytest.skip("Test a skip error inside asyncio")
34+
"""
35+
)
36+
)
37+
result = pytester.runpytest("--asyncio-mode=auto")
38+
result.assert_outcomes(skipped=1)

tests/test_simple.py

-35
Original file line numberDiff line numberDiff line change
@@ -100,41 +100,6 @@ async def test_event_loop_before_fixture(self, loop):
100100
assert await loop.run_in_executor(None, self.foo) == 1
101101

102102

103-
def test_asyncio_marker_compatibility_with_skip(pytester: Pytester):
104-
pytester.makepyfile(
105-
dedent(
106-
"""\
107-
import pytest
108-
109-
pytest_plugins = "pytest_asyncio"
110-
111-
@pytest.mark.asyncio
112-
async def test_no_warning_on_skip():
113-
pytest.skip("Test a skip error inside asyncio")
114-
"""
115-
)
116-
)
117-
result = pytester.runpytest("--asyncio-mode=strict")
118-
result.assert_outcomes(skipped=1)
119-
120-
121-
def test_asyncio_auto_mode_compatibility_with_skip(pytester: Pytester):
122-
pytester.makepyfile(
123-
dedent(
124-
"""\
125-
import pytest
126-
127-
pytest_plugins = "pytest_asyncio"
128-
129-
async def test_no_warning_on_skip():
130-
pytest.skip("Test a skip error inside asyncio")
131-
"""
132-
)
133-
)
134-
result = pytester.runpytest("--asyncio-mode=auto")
135-
result.assert_outcomes(skipped=1)
136-
137-
138103
def test_invalid_asyncio_mode(testdir):
139104
result = testdir.runpytest("-o", "asyncio_mode=True")
140105
result.stderr.no_fnmatch_line("INTERNALERROR> *")

0 commit comments

Comments
 (0)