1
1
from textwrap import dedent
2
2
3
+ from pytest import Pytester
3
4
4
- def test_auto_mode_cmdline (testdir ):
5
- testdir .makepyfile (
5
+
6
+ def test_auto_mode_cmdline (pytester : Pytester ):
7
+ pytester .makepyfile (
6
8
dedent (
7
9
"""\
8
10
import asyncio
@@ -15,12 +17,12 @@ async def test_a():
15
17
"""
16
18
)
17
19
)
18
- result = testdir .runpytest ("--asyncio-mode=auto" )
20
+ result = pytester .runpytest ("--asyncio-mode=auto" )
19
21
result .assert_outcomes (passed = 1 )
20
22
21
23
22
- def test_auto_mode_cfg (testdir ):
23
- testdir .makepyfile (
24
+ def test_auto_mode_cfg (pytester : Pytester ):
25
+ pytester .makepyfile (
24
26
dedent (
25
27
"""\
26
28
import asyncio
@@ -33,13 +35,13 @@ async def test_a():
33
35
"""
34
36
)
35
37
)
36
- testdir .makefile (".ini" , pytest = "[pytest]\n asyncio_mode = auto\n " )
37
- result = testdir .runpytest ()
38
+ pytester .makefile (".ini" , pytest = "[pytest]\n asyncio_mode = auto\n " )
39
+ result = pytester .runpytest ()
38
40
result .assert_outcomes (passed = 1 )
39
41
40
42
41
- def test_auto_mode_async_fixture (testdir ):
42
- testdir .makepyfile (
43
+ def test_auto_mode_async_fixture (pytester : Pytester ):
44
+ pytester .makepyfile (
43
45
dedent (
44
46
"""\
45
47
import asyncio
@@ -58,12 +60,12 @@ async def test_a(fixture_a):
58
60
"""
59
61
)
60
62
)
61
- result = testdir .runpytest ("--asyncio-mode=auto" )
63
+ result = pytester .runpytest ("--asyncio-mode=auto" )
62
64
result .assert_outcomes (passed = 1 )
63
65
64
66
65
- def test_auto_mode_method_fixture (testdir ):
66
- testdir .makepyfile (
67
+ def test_auto_mode_method_fixture (pytester : Pytester ):
68
+ pytester .makepyfile (
67
69
dedent (
68
70
"""\
69
71
import asyncio
@@ -85,12 +87,12 @@ async def test_a(self, fixture_a):
85
87
"""
86
88
)
87
89
)
88
- result = testdir .runpytest ("--asyncio-mode=auto" )
90
+ result = pytester .runpytest ("--asyncio-mode=auto" )
89
91
result .assert_outcomes (passed = 1 )
90
92
91
93
92
- def test_auto_mode_static_method (testdir ):
93
- testdir .makepyfile (
94
+ def test_auto_mode_static_method (pytester : Pytester ):
95
+ pytester .makepyfile (
94
96
dedent (
95
97
"""\
96
98
import asyncio
@@ -106,12 +108,12 @@ async def test_a():
106
108
"""
107
109
)
108
110
)
109
- result = testdir .runpytest ("--asyncio-mode=auto" )
111
+ result = pytester .runpytest ("--asyncio-mode=auto" )
110
112
result .assert_outcomes (passed = 1 )
111
113
112
114
113
- def test_auto_mode_static_method_fixture (testdir ):
114
- testdir .makepyfile (
115
+ def test_auto_mode_static_method_fixture (pytester : Pytester ):
116
+ pytester .makepyfile (
115
117
dedent (
116
118
"""\
117
119
import asyncio
@@ -135,5 +137,5 @@ async def test_a(fixture_a):
135
137
"""
136
138
)
137
139
)
138
- result = testdir .runpytest ("--asyncio-mode=auto" )
140
+ result = pytester .runpytest ("--asyncio-mode=auto" )
139
141
result .assert_outcomes (passed = 1 )
0 commit comments