Skip to content

Commit 5a474bd

Browse files
committed
[refactor] Moved test for warning generated when sync functions are marked with "asyncio" into a separate test module.
The "test_simple" module is named too general. Thus, it serves as a magnet for all kinds of tests that aren't connected to each other. This is one step to break up the "test_simple" module into more coherent test modules. Signed-off-by: Michael Seifert <[email protected]>
1 parent 660893d commit 5a474bd

File tree

2 files changed

+33
-32
lines changed

2 files changed

+33
-32
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from textwrap import dedent
2+
3+
4+
def test_warn_asyncio_marker_for_regular_func(testdir):
5+
testdir.makepyfile(
6+
dedent(
7+
"""\
8+
import pytest
9+
10+
pytest_plugins = 'pytest_asyncio'
11+
12+
@pytest.mark.asyncio
13+
def test_a():
14+
pass
15+
"""
16+
)
17+
)
18+
testdir.makefile(
19+
".ini",
20+
pytest=dedent(
21+
"""\
22+
[pytest]
23+
asyncio_mode = strict
24+
filterwarnings =
25+
default
26+
"""
27+
),
28+
)
29+
result = testdir.runpytest()
30+
result.assert_outcomes(passed=1)
31+
result.stdout.fnmatch_lines(
32+
["*is marked with '@pytest.mark.asyncio' but it is not an async function.*"]
33+
)

tests/test_simple.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -300,38 +300,6 @@ async def test_no_warning_on_skip():
300300
result.assert_outcomes(skipped=1)
301301

302302

303-
def test_warn_asyncio_marker_for_regular_func(testdir):
304-
testdir.makepyfile(
305-
dedent(
306-
"""\
307-
import pytest
308-
309-
pytest_plugins = 'pytest_asyncio'
310-
311-
@pytest.mark.asyncio
312-
def test_a():
313-
pass
314-
"""
315-
)
316-
)
317-
testdir.makefile(
318-
".ini",
319-
pytest=dedent(
320-
"""\
321-
[pytest]
322-
asyncio_mode = strict
323-
filterwarnings =
324-
default
325-
"""
326-
),
327-
)
328-
result = testdir.runpytest()
329-
result.assert_outcomes(passed=1)
330-
result.stdout.fnmatch_lines(
331-
["*is marked with '@pytest.mark.asyncio' but it is not an async function.*"]
332-
)
333-
334-
335303
def test_invalid_asyncio_mode(testdir):
336304
result = testdir.runpytest("-o", "asyncio_mode=True")
337305
result.stderr.no_fnmatch_line("INTERNALERROR> *")

0 commit comments

Comments
 (0)