Skip to content

Commit 3de231e

Browse files
committed
refactor: Addressed warnings about missing default fixture loop in tests/markers/test_class_scope.py.
1 parent dd4e982 commit 3de231e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tests/markers/test_class_scope.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def sample_fixture():
3030
def test_asyncio_mark_provides_class_scoped_loop_when_applied_to_functions(
3131
pytester: pytest.Pytester,
3232
):
33+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
3334
pytester.makepyfile(
3435
dedent(
3536
"""\
@@ -56,6 +57,7 @@ async def test_this_runs_in_same_loop(self):
5657
def test_asyncio_mark_provides_class_scoped_loop_when_applied_to_class(
5758
pytester: pytest.Pytester,
5859
):
60+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
5961
pytester.makepyfile(
6062
dedent(
6163
"""\
@@ -81,6 +83,7 @@ async def test_this_runs_in_same_loop(self):
8183
def test_asyncio_mark_raises_when_class_scoped_is_request_without_class(
8284
pytester: pytest.Pytester,
8385
):
86+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
8487
pytester.makepyfile(
8588
dedent(
8689
"""\
@@ -101,6 +104,7 @@ async def test_has_no_surrounding_class():
101104

102105

103106
def test_asyncio_mark_is_inherited_to_subclasses(pytester: pytest.Pytester):
107+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
104108
pytester.makepyfile(
105109
dedent(
106110
"""\
@@ -129,6 +133,7 @@ async def test_this_runs_in_same_loop(self):
129133
def test_asyncio_mark_respects_the_loop_policy(
130134
pytester: pytest.Pytester,
131135
):
136+
pytester.makeini("[pytest]\nasyncio_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():
166171
def test_asyncio_mark_respects_parametrized_loop_policies(
167172
pytester: pytest.Pytester,
168173
):
174+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
169175
pytester.makepyfile(
170176
dedent(
171177
"""\
@@ -197,6 +203,7 @@ async def test_parametrized_loop(self, request):
197203
def test_asyncio_mark_provides_class_scoped_loop_to_fixtures(
198204
pytester: pytest.Pytester,
199205
):
206+
pytester.makeini("[pytest]\nasyncio_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):
226233
def test_asyncio_mark_allows_combining_class_scoped_fixture_with_function_scoped_test(
227234
pytester: pytest.Pytester,
228235
):
236+
pytester.makeini("[pytest]\nasyncio_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):
257265
def test_asyncio_mark_handles_missing_event_loop_triggered_by_fixture(
258266
pytester: pytest.Pytester,
259267
):
268+
pytester.makeini("[pytest]\nasyncio_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):
292301
def test_standalone_test_does_not_trigger_warning_about_no_current_event_loop_being_set(
293302
pytester: pytest.Pytester,
294303
):
304+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
295305
pytester.makepyfile(
296306
dedent(
297307
"""\

0 commit comments

Comments
 (0)