4
4
5
5
6
6
def test_asyncio_mark_works_on_module_level (pytester : Pytester ):
7
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
7
8
pytester .makepyfile (
8
9
dedent (
9
10
"""\
@@ -56,6 +57,7 @@ def sample_fixture():
56
57
57
58
58
59
def test_asyncio_mark_provides_module_scoped_loop_strict_mode (pytester : Pytester ):
60
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
59
61
pytester .makepyfile (
60
62
dedent (
61
63
"""\
@@ -88,6 +90,7 @@ async def test_this_runs_in_same_loop(self):
88
90
def test_raise_when_event_loop_fixture_is_requested_in_addition_to_scoped_loop (
89
91
pytester : Pytester ,
90
92
):
93
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
91
94
pytester .makepyfile (
92
95
dedent (
93
96
"""\
@@ -109,6 +112,7 @@ async def test_remember_loop(event_loop):
109
112
def test_asyncio_mark_respects_the_loop_policy (
110
113
pytester : Pytester ,
111
114
):
115
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
112
116
pytester .makepyfile (
113
117
__init__ = "" ,
114
118
custom_policy = dedent (
@@ -163,6 +167,7 @@ async def test_does_not_use_custom_event_loop_policy():
163
167
def test_asyncio_mark_respects_parametrized_loop_policies (
164
168
pytester : Pytester ,
165
169
):
170
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
166
171
pytester .makepyfile (
167
172
dedent (
168
173
"""\
@@ -194,6 +199,7 @@ async def test_parametrized_loop():
194
199
def test_asyncio_mark_provides_module_scoped_loop_to_fixtures (
195
200
pytester : Pytester ,
196
201
):
202
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
197
203
pytester .makepyfile (
198
204
dedent (
199
205
"""\
@@ -206,7 +212,7 @@ def test_asyncio_mark_provides_module_scoped_loop_to_fixtures(
206
212
207
213
loop: asyncio.AbstractEventLoop
208
214
209
- @pytest_asyncio.fixture(scope="module")
215
+ @pytest_asyncio.fixture(loop_scope="module", scope="module")
210
216
async def my_fixture():
211
217
global loop
212
218
loop = asyncio.get_running_loop()
@@ -224,6 +230,7 @@ async def test_runs_is_same_loop_as_fixture(my_fixture):
224
230
def test_asyncio_mark_allows_combining_module_scoped_fixture_with_class_scoped_test (
225
231
pytester : Pytester ,
226
232
):
233
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
227
234
pytester .makepyfile (
228
235
dedent (
229
236
"""\
@@ -234,7 +241,7 @@ def test_asyncio_mark_allows_combining_module_scoped_fixture_with_class_scoped_t
234
241
235
242
loop: asyncio.AbstractEventLoop
236
243
237
- @pytest_asyncio.fixture(scope="module")
244
+ @pytest_asyncio.fixture(loop_scope="module", scope="module")
238
245
async def async_fixture():
239
246
global loop
240
247
loop = asyncio.get_running_loop()
@@ -255,6 +262,7 @@ async def test_runs_in_different_loop_as_fixture(self, async_fixture):
255
262
def test_asyncio_mark_allows_combining_module_scoped_fixture_with_function_scoped_test (
256
263
pytester : Pytester ,
257
264
):
265
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
258
266
pytester .makepyfile (
259
267
__init__ = "" ,
260
268
test_mixed_scopes = dedent (
@@ -266,7 +274,7 @@ def test_asyncio_mark_allows_combining_module_scoped_fixture_with_function_scope
266
274
267
275
loop: asyncio.AbstractEventLoop
268
276
269
- @pytest_asyncio.fixture(scope="module")
277
+ @pytest_asyncio.fixture(loop_scope="module", scope="module")
270
278
async def async_fixture():
271
279
global loop
272
280
loop = asyncio.get_running_loop()
@@ -285,6 +293,7 @@ async def test_runs_in_different_loop_as_fixture(async_fixture):
285
293
def test_allows_combining_module_scoped_asyncgen_fixture_with_function_scoped_test (
286
294
pytester : Pytester ,
287
295
):
296
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
288
297
pytester .makepyfile (
289
298
dedent (
290
299
"""\
@@ -295,7 +304,7 @@ def test_allows_combining_module_scoped_asyncgen_fixture_with_function_scoped_te
295
304
296
305
loop: asyncio.AbstractEventLoop
297
306
298
- @pytest_asyncio.fixture(scope="module")
307
+ @pytest_asyncio.fixture(loop_scope="module", scope="module")
299
308
async def async_fixture():
300
309
global loop
301
310
loop = asyncio.get_running_loop()
@@ -315,6 +324,7 @@ async def test_runs_in_different_loop_as_fixture(async_fixture):
315
324
def test_asyncio_mark_handles_missing_event_loop_triggered_by_fixture (
316
325
pytester : Pytester ,
317
326
):
327
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
318
328
pytester .makepyfile (
319
329
dedent (
320
330
"""\
@@ -349,6 +359,7 @@ async def test_does_not_fail(sets_event_loop_to_none, n):
349
359
def test_standalone_test_does_not_trigger_warning_about_no_current_event_loop_being_set (
350
360
pytester : Pytester ,
351
361
):
362
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
352
363
pytester .makepyfile (
353
364
dedent (
354
365
"""\
0 commit comments