Skip to content

Commit e8570f2

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

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/markers/test_function_scope.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55

66
def test_asyncio_mark_provides_function_scoped_loop_strict_mode(pytester: Pytester):
7+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
78
pytester.makepyfile(
89
dedent(
910
"""\
@@ -29,6 +30,7 @@ async def test_does_not_run_in_same_loop():
2930

3031

3132
def test_loop_scope_function_provides_function_scoped_event_loop(pytester: Pytester):
33+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
3234
pytester.makepyfile(
3335
dedent(
3436
"""\
@@ -54,6 +56,7 @@ async def test_does_not_run_in_same_loop():
5456

5557

5658
def test_raises_when_scope_and_loop_scope_arguments_are_present(pytester: Pytester):
59+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
5760
pytester.makepyfile(
5861
dedent(
5962
"""\
@@ -70,6 +73,7 @@ async def test_raises():
7073

7174

7275
def test_warns_when_scope_argument_is_present(pytester: Pytester):
76+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
7377
pytester.makepyfile(
7478
dedent(
7579
"""\
@@ -89,6 +93,7 @@ async def test_warns():
8993
def test_function_scope_supports_explicit_event_loop_fixture_request(
9094
pytester: Pytester,
9195
):
96+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
9297
pytester.makepyfile(
9398
dedent(
9499
"""\
@@ -111,6 +116,7 @@ async def test_remember_loop(event_loop):
111116
def test_asyncio_mark_respects_the_loop_policy(
112117
pytester: Pytester,
113118
):
119+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
114120
pytester.makepyfile(
115121
dedent(
116122
"""\
@@ -141,6 +147,7 @@ async def test_uses_custom_event_loop_policy():
141147
def test_asyncio_mark_respects_parametrized_loop_policies(
142148
pytester: Pytester,
143149
):
150+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
144151
pytester.makepyfile(
145152
dedent(
146153
"""\
@@ -178,6 +185,7 @@ async def test_parametrized_loop():
178185
def test_asyncio_mark_provides_function_scoped_loop_to_fixtures(
179186
pytester: Pytester,
180187
):
188+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
181189
pytester.makepyfile(
182190
dedent(
183191
"""\
@@ -208,6 +216,7 @@ async def test_runs_is_same_loop_as_fixture(my_fixture):
208216
def test_asyncio_mark_handles_missing_event_loop_triggered_by_fixture(
209217
pytester: Pytester,
210218
):
219+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
211220
pytester.makepyfile(
212221
dedent(
213222
"""\
@@ -242,6 +251,7 @@ async def test_does_not_fail(sets_event_loop_to_none, n):
242251
def test_standalone_test_does_not_trigger_warning_about_no_current_event_loop_being_set(
243252
pytester: Pytester,
244253
):
254+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
245255
pytester.makepyfile(
246256
dedent(
247257
"""\
@@ -260,6 +270,7 @@ async def test_anything():
260270
def test_asyncio_mark_does_not_duplicate_other_marks_in_auto_mode(
261271
pytester: Pytester,
262272
):
273+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
263274
pytester.makeconftest(
264275
dedent(
265276
"""\

0 commit comments

Comments
 (0)