@@ -30,6 +30,7 @@ def sample_fixture():
3030def test_asyncio_mark_provides_class_scoped_loop_when_applied_to_functions (
3131 pytester : pytest .Pytester ,
3232):
33+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
3334 pytester .makepyfile (
3435 dedent (
3536 """\
@@ -56,6 +57,7 @@ async def test_this_runs_in_same_loop(self):
5657def test_asyncio_mark_provides_class_scoped_loop_when_applied_to_class (
5758 pytester : pytest .Pytester ,
5859):
60+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
5961 pytester .makepyfile (
6062 dedent (
6163 """\
@@ -81,6 +83,7 @@ async def test_this_runs_in_same_loop(self):
8183def test_asyncio_mark_raises_when_class_scoped_is_request_without_class (
8284 pytester : pytest .Pytester ,
8385):
86+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
8487 pytester .makepyfile (
8588 dedent (
8689 """\
@@ -101,6 +104,7 @@ async def test_has_no_surrounding_class():
101104
102105
103106def test_asyncio_mark_is_inherited_to_subclasses (pytester : pytest .Pytester ):
107+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
104108 pytester .makepyfile (
105109 dedent (
106110 """\
@@ -129,6 +133,7 @@ async def test_this_runs_in_same_loop(self):
129133def test_asyncio_mark_respects_the_loop_policy (
130134 pytester : pytest .Pytester ,
131135):
136+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
132137 pytester .makepyfile (
133138 dedent (
134139 """\
@@ -166,6 +171,7 @@ async def test_does_not_use_custom_event_loop_policy():
166171def test_asyncio_mark_respects_parametrized_loop_policies (
167172 pytester : pytest .Pytester ,
168173):
174+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
169175 pytester .makepyfile (
170176 dedent (
171177 """\
@@ -197,6 +203,7 @@ async def test_parametrized_loop(self, request):
197203def test_asyncio_mark_provides_class_scoped_loop_to_fixtures (
198204 pytester : pytest .Pytester ,
199205):
206+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
200207 pytester .makepyfile (
201208 dedent (
202209 """\
@@ -226,6 +233,7 @@ async def test_runs_is_same_loop_as_fixture(self, my_fixture):
226233def test_asyncio_mark_allows_combining_class_scoped_fixture_with_function_scoped_test (
227234 pytester : pytest .Pytester ,
228235):
236+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
229237 pytester .makepyfile (
230238 dedent (
231239 """\
@@ -237,7 +245,7 @@ def test_asyncio_mark_allows_combining_class_scoped_fixture_with_function_scoped
237245 loop: asyncio.AbstractEventLoop
238246
239247 class TestMixedScopes:
240- @pytest_asyncio.fixture(scope="class")
248+ @pytest_asyncio.fixture(loop_scope="class", scope="class")
241249 async def async_fixture(self):
242250 global loop
243251 loop = asyncio.get_running_loop()
@@ -257,6 +265,7 @@ async def test_runs_in_different_loop_as_fixture(self, async_fixture):
257265def test_asyncio_mark_handles_missing_event_loop_triggered_by_fixture (
258266 pytester : pytest .Pytester ,
259267):
268+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
260269 pytester .makepyfile (
261270 dedent (
262271 """\
@@ -292,6 +301,7 @@ async def test_does_not_fail(self, sets_event_loop_to_none, n):
292301def test_standalone_test_does_not_trigger_warning_about_no_current_event_loop_being_set (
293302 pytester : pytest .Pytester ,
294303):
304+ pytester .makeini ("[pytest]\n asyncio_default_fixture_loop_scope = function" )
295305 pytester .makepyfile (
296306 dedent (
297307 """\
0 commit comments