1
1
from textwrap import dedent
2
2
3
+ from pytest import Pytester
3
4
4
- def test_strict_mode_cmdline (testdir ):
5
- testdir .makepyfile (
5
+
6
+ def test_strict_mode_cmdline (pytester : Pytester ):
7
+ pytester .makepyfile (
6
8
dedent (
7
9
"""\
8
10
import asyncio
@@ -16,12 +18,12 @@ async def test_a():
16
18
"""
17
19
)
18
20
)
19
- result = testdir .runpytest ("--asyncio-mode=strict" )
21
+ result = pytester .runpytest ("--asyncio-mode=strict" )
20
22
result .assert_outcomes (passed = 1 )
21
23
22
24
23
- def test_strict_mode_cfg (testdir ):
24
- testdir .makepyfile (
25
+ def test_strict_mode_cfg (pytester : Pytester ):
26
+ pytester .makepyfile (
25
27
dedent (
26
28
"""\
27
29
import asyncio
@@ -35,13 +37,13 @@ async def test_a():
35
37
"""
36
38
)
37
39
)
38
- testdir .makefile (".ini" , pytest = "[pytest]\n asyncio_mode = strict\n " )
39
- result = testdir .runpytest ()
40
+ pytester .makefile (".ini" , pytest = "[pytest]\n asyncio_mode = strict\n " )
41
+ result = pytester .runpytest ()
40
42
result .assert_outcomes (passed = 1 )
41
43
42
44
43
- def test_strict_mode_method_fixture (testdir ):
44
- testdir .makepyfile (
45
+ def test_strict_mode_method_fixture (pytester : Pytester ):
46
+ pytester .makepyfile (
45
47
dedent (
46
48
"""\
47
49
import asyncio
@@ -64,12 +66,12 @@ async def test_a(self, fixture_a):
64
66
"""
65
67
)
66
68
)
67
- result = testdir .runpytest ("--asyncio-mode=auto" )
69
+ result = pytester .runpytest ("--asyncio-mode=auto" )
68
70
result .assert_outcomes (passed = 1 )
69
71
70
72
71
- def test_strict_mode_ignores_unmarked_coroutine (testdir ):
72
- testdir .makepyfile (
73
+ def test_strict_mode_ignores_unmarked_coroutine (pytester : Pytester ):
74
+ pytester .makepyfile (
73
75
dedent (
74
76
"""\
75
77
import pytest
@@ -79,13 +81,13 @@ async def test_anything():
79
81
"""
80
82
)
81
83
)
82
- result = testdir .runpytest_subprocess ("--asyncio-mode=strict" , "-W default" )
84
+ result = pytester .runpytest_subprocess ("--asyncio-mode=strict" , "-W default" )
83
85
result .assert_outcomes (skipped = 1 , warnings = 1 )
84
86
result .stdout .fnmatch_lines (["*async def functions are not natively supported*" ])
85
87
86
88
87
- def test_strict_mode_ignores_unmarked_fixture (testdir ):
88
- testdir .makepyfile (
89
+ def test_strict_mode_ignores_unmarked_fixture (pytester : Pytester ):
90
+ pytester .makepyfile (
89
91
dedent (
90
92
"""\
91
93
import pytest
@@ -100,7 +102,7 @@ async def test_anything(any_fixture):
100
102
"""
101
103
)
102
104
)
103
- result = testdir .runpytest_subprocess ("--asyncio-mode=strict" , "-W default" )
105
+ result = pytester .runpytest_subprocess ("--asyncio-mode=strict" , "-W default" )
104
106
result .assert_outcomes (skipped = 1 , warnings = 2 )
105
107
result .stdout .fnmatch_lines (
106
108
[
0 commit comments