6
6
def test_asyncio_mark_provides_package_scoped_loop_strict_mode (pytester : Pytester ):
7
7
package_name = pytester .path .name
8
8
subpackage_name = "subpkg"
9
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
9
10
pytester .makepyfile (
10
11
__init__ = "" ,
11
12
shared_module = dedent (
@@ -69,6 +70,7 @@ async def test_subpackage_runs_in_different_loop():
69
70
def test_raise_when_event_loop_fixture_is_requested_in_addition_to_scoped_loop (
70
71
pytester : Pytester ,
71
72
):
73
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
72
74
pytester .makepyfile (
73
75
__init__ = "" ,
74
76
test_raises = dedent (
@@ -90,6 +92,7 @@ async def test_remember_loop(event_loop):
90
92
def test_asyncio_mark_respects_the_loop_policy (
91
93
pytester : Pytester ,
92
94
):
95
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
93
96
pytester .makepyfile (
94
97
__init__ = "" ,
95
98
conftest = dedent (
@@ -151,6 +154,7 @@ async def test_also_uses_custom_event_loop_policy():
151
154
def test_asyncio_mark_respects_parametrized_loop_policies (
152
155
pytester : Pytester ,
153
156
):
157
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
154
158
pytester .makepyfile (
155
159
__init__ = "" ,
156
160
test_parametrization = dedent (
@@ -183,6 +187,7 @@ async def test_parametrized_loop():
183
187
def test_asyncio_mark_provides_package_scoped_loop_to_fixtures (
184
188
pytester : Pytester ,
185
189
):
190
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
186
191
package_name = pytester .path .name
187
192
pytester .makepyfile (
188
193
__init__ = "" ,
@@ -194,7 +199,7 @@ def test_asyncio_mark_provides_package_scoped_loop_to_fixtures(
194
199
195
200
from { package_name } import shared_module
196
201
197
- @pytest_asyncio.fixture(scope="package")
202
+ @pytest_asyncio.fixture(loop_scope="package", scope="package")
198
203
async def my_fixture():
199
204
shared_module.loop = asyncio.get_running_loop()
200
205
"""
@@ -229,6 +234,7 @@ async def test_runs_in_same_loop_as_fixture(my_fixture):
229
234
def test_asyncio_mark_allows_combining_package_scoped_fixture_with_module_scoped_test (
230
235
pytester : Pytester ,
231
236
):
237
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
232
238
pytester .makepyfile (
233
239
__init__ = "" ,
234
240
test_mixed_scopes = dedent (
@@ -240,7 +246,7 @@ def test_asyncio_mark_allows_combining_package_scoped_fixture_with_module_scoped
240
246
241
247
loop: asyncio.AbstractEventLoop
242
248
243
- @pytest_asyncio.fixture(scope="package")
249
+ @pytest_asyncio.fixture(loop_scope="package", scope="package")
244
250
async def async_fixture():
245
251
global loop
246
252
loop = asyncio.get_running_loop()
@@ -259,6 +265,7 @@ async def test_runs_in_different_loop_as_fixture(async_fixture):
259
265
def test_asyncio_mark_allows_combining_package_scoped_fixture_with_class_scoped_test (
260
266
pytester : Pytester ,
261
267
):
268
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
262
269
pytester .makepyfile (
263
270
__init__ = "" ,
264
271
test_mixed_scopes = dedent (
@@ -270,7 +277,7 @@ def test_asyncio_mark_allows_combining_package_scoped_fixture_with_class_scoped_
270
277
271
278
loop: asyncio.AbstractEventLoop
272
279
273
- @pytest_asyncio.fixture(scope="package")
280
+ @pytest_asyncio.fixture(loop_scope="package", scope="package")
274
281
async def async_fixture():
275
282
global loop
276
283
loop = asyncio.get_running_loop()
@@ -290,6 +297,7 @@ async def test_runs_in_different_loop_as_fixture(self, async_fixture):
290
297
def test_asyncio_mark_allows_combining_package_scoped_fixture_with_function_scoped_test (
291
298
pytester : Pytester ,
292
299
):
300
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
293
301
pytester .makepyfile (
294
302
__init__ = "" ,
295
303
test_mixed_scopes = dedent (
@@ -301,7 +309,7 @@ def test_asyncio_mark_allows_combining_package_scoped_fixture_with_function_scop
301
309
302
310
loop: asyncio.AbstractEventLoop
303
311
304
- @pytest_asyncio.fixture(scope="package")
312
+ @pytest_asyncio.fixture(loop_scope="package", scope="package")
305
313
async def async_fixture():
306
314
global loop
307
315
loop = asyncio.get_running_loop()
@@ -320,6 +328,7 @@ async def test_runs_in_different_loop_as_fixture(async_fixture):
320
328
def test_asyncio_mark_handles_missing_event_loop_triggered_by_fixture (
321
329
pytester : Pytester ,
322
330
):
331
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
323
332
pytester .makepyfile (
324
333
__init__ = "" ,
325
334
test_loop_is_none = dedent (
@@ -355,6 +364,7 @@ async def test_does_not_fail(sets_event_loop_to_none, n):
355
364
def test_standalone_test_does_not_trigger_warning_about_no_current_event_loop_being_set (
356
365
pytester : Pytester ,
357
366
):
367
+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
358
368
pytester .makepyfile (
359
369
__init__ = "" ,
360
370
test_module = dedent (
0 commit comments