Skip to content

Commit bada7ba

Browse files
committed
refactor: Addressed warnings about missing default fixture loop scope in tests/modes/test_auto_mode.py.
1 parent a4dffa2 commit bada7ba

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

tests/modes/test_auto_mode.py

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

55

66
def test_auto_mode_cmdline(pytester: Pytester):
7+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
78
pytester.makepyfile(
89
dedent(
910
"""\
@@ -22,6 +23,15 @@ async def test_a():
2223

2324

2425
def test_auto_mode_cfg(pytester: Pytester):
26+
pytester.makeini(
27+
dedent(
28+
"""\
29+
[pytest]
30+
asyncio_default_fixture_loop_scope = function
31+
asyncio_mode = auto
32+
"""
33+
)
34+
)
2535
pytester.makepyfile(
2636
dedent(
2737
"""\
@@ -35,12 +45,12 @@ async def test_a():
3545
"""
3646
)
3747
)
38-
pytester.makefile(".ini", pytest="[pytest]\nasyncio_mode = auto\n")
39-
result = pytester.runpytest()
48+
result = pytester.runpytest("--asyncio-mode=auto")
4049
result.assert_outcomes(passed=1)
4150

4251

4352
def test_auto_mode_async_fixture(pytester: Pytester):
53+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
4454
pytester.makepyfile(
4555
dedent(
4656
"""\
@@ -65,6 +75,7 @@ async def test_a(fixture_a):
6575

6676

6777
def test_auto_mode_method_fixture(pytester: Pytester):
78+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
6879
pytester.makepyfile(
6980
dedent(
7081
"""\
@@ -92,6 +103,7 @@ async def test_a(self, fixture_a):
92103

93104

94105
def test_auto_mode_static_method(pytester: Pytester):
106+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
95107
pytester.makepyfile(
96108
dedent(
97109
"""\
@@ -113,6 +125,7 @@ async def test_a():
113125

114126

115127
def test_auto_mode_static_method_fixture(pytester: Pytester):
128+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
116129
pytester.makepyfile(
117130
dedent(
118131
"""\

0 commit comments

Comments
 (0)