@@ -30,6 +30,7 @@ def sample_fixture():
30
30
def test_asyncio_mark_provides_class_scoped_loop_when_applied_to_functions (
31
31
pytester : pytest .Pytester ,
32
32
):
33
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
33
34
pytester .makepyfile (
34
35
dedent (
35
36
"""\
@@ -56,6 +57,7 @@ async def test_this_runs_in_same_loop(self):
56
57
def test_asyncio_mark_provides_class_scoped_loop_when_applied_to_class (
57
58
pytester : pytest .Pytester ,
58
59
):
60
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
59
61
pytester .makepyfile (
60
62
dedent (
61
63
"""\
@@ -81,6 +83,7 @@ async def test_this_runs_in_same_loop(self):
81
83
def test_asyncio_mark_raises_when_class_scoped_is_request_without_class (
82
84
pytester : pytest .Pytester ,
83
85
):
86
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
84
87
pytester .makepyfile (
85
88
dedent (
86
89
"""\
@@ -101,6 +104,7 @@ async def test_has_no_surrounding_class():
101
104
102
105
103
106
def test_asyncio_mark_is_inherited_to_subclasses (pytester : pytest .Pytester ):
107
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
104
108
pytester .makepyfile (
105
109
dedent (
106
110
"""\
@@ -129,6 +133,7 @@ async def test_this_runs_in_same_loop(self):
129
133
def test_asyncio_mark_respects_the_loop_policy (
130
134
pytester : pytest .Pytester ,
131
135
):
136
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
132
137
pytester .makepyfile (
133
138
dedent (
134
139
"""\
@@ -166,6 +171,7 @@ async def test_does_not_use_custom_event_loop_policy():
166
171
def test_asyncio_mark_respects_parametrized_loop_policies (
167
172
pytester : pytest .Pytester ,
168
173
):
174
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
169
175
pytester .makepyfile (
170
176
dedent (
171
177
"""\
@@ -197,6 +203,7 @@ async def test_parametrized_loop(self, request):
197
203
def test_asyncio_mark_provides_class_scoped_loop_to_fixtures (
198
204
pytester : pytest .Pytester ,
199
205
):
206
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
200
207
pytester .makepyfile (
201
208
dedent (
202
209
"""\
@@ -226,6 +233,7 @@ async def test_runs_is_same_loop_as_fixture(self, my_fixture):
226
233
def test_asyncio_mark_allows_combining_class_scoped_fixture_with_function_scoped_test (
227
234
pytester : pytest .Pytester ,
228
235
):
236
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
229
237
pytester .makepyfile (
230
238
dedent (
231
239
"""\
@@ -237,7 +245,7 @@ def test_asyncio_mark_allows_combining_class_scoped_fixture_with_function_scoped
237
245
loop: asyncio.AbstractEventLoop
238
246
239
247
class TestMixedScopes:
240
- @pytest_asyncio.fixture(scope="class")
248
+ @pytest_asyncio.fixture(loop_scope="class", scope="class")
241
249
async def async_fixture(self):
242
250
global loop
243
251
loop = asyncio.get_running_loop()
@@ -257,6 +265,7 @@ async def test_runs_in_different_loop_as_fixture(self, async_fixture):
257
265
def test_asyncio_mark_handles_missing_event_loop_triggered_by_fixture (
258
266
pytester : pytest .Pytester ,
259
267
):
268
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
260
269
pytester .makepyfile (
261
270
dedent (
262
271
"""\
@@ -292,6 +301,7 @@ async def test_does_not_fail(self, sets_event_loop_to_none, n):
292
301
def test_standalone_test_does_not_trigger_warning_about_no_current_event_loop_being_set (
293
302
pytester : pytest .Pytester ,
294
303
):
304
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
295
305
pytester .makepyfile (
296
306
dedent (
297
307
"""\
0 commit comments