Skip to content

Commit 60af27b

Browse files
committed
refactor: Addressed warnigs about missing default fixture loop scope in tests/test_is_async_test.py, tests/test_simple.py, and tests/test_skips.py.
1 parent 9fa18dd commit 60af27b

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

tests/test_is_async_test.py

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55

66
def test_returns_false_for_sync_item(pytester: Pytester):
7+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
78
pytester.makepyfile(
89
dedent(
910
"""\
@@ -28,6 +29,7 @@ def pytest_collection_modifyitems(items):
2829

2930

3031
def test_returns_true_for_marked_coroutine_item_in_strict_mode(pytester: Pytester):
32+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
3133
pytester.makepyfile(
3234
dedent(
3335
"""\
@@ -53,6 +55,7 @@ def pytest_collection_modifyitems(items):
5355

5456

5557
def test_returns_false_for_unmarked_coroutine_item_in_strict_mode(pytester: Pytester):
58+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
5659
pytester.makepyfile(
5760
dedent(
5861
"""\
@@ -77,6 +80,7 @@ def pytest_collection_modifyitems(items):
7780

7881

7982
def test_returns_true_for_unmarked_coroutine_item_in_auto_mode(pytester: Pytester):
83+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
8084
pytester.makepyfile(
8185
dedent(
8286
"""\

tests/test_simple.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ async def test_asyncio_marker():
2626

2727

2828
def test_asyncio_marker_compatibility_with_xfail(pytester: Pytester):
29+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
2930
pytester.makepyfile(
3031
dedent(
3132
"""\
@@ -45,6 +46,7 @@ async def test_asyncio_marker_fail():
4546

4647

4748
def test_asyncio_auto_mode_compatibility_with_xfail(pytester: Pytester):
49+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
4850
pytester.makepyfile(
4951
dedent(
5052
"""\
@@ -101,8 +103,9 @@ async def test_event_loop_before_fixture(self, loop):
101103
assert await loop.run_in_executor(None, self.foo) == 1
102104

103105

104-
def test_invalid_asyncio_mode(testdir):
105-
result = testdir.runpytest("-o", "asyncio_mode=True")
106+
def test_invalid_asyncio_mode(pytester):
107+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
108+
result = pytester.runpytest("-o", "asyncio_mode=True")
106109
result.stderr.no_fnmatch_line("INTERNALERROR> *")
107110
result.stderr.fnmatch_lines(
108111
"ERROR: 'True' is not a valid asyncio_mode. Valid modes: auto, strict."

tests/test_skips.py

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55

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

2324

2425
def test_asyncio_auto_mode_skip(pytester: Pytester):
26+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
2527
pytester.makepyfile(
2628
dedent(
2729
"""\
@@ -39,6 +41,7 @@ async def test_no_warning_on_skip():
3941

4042

4143
def test_asyncio_strict_mode_module_level_skip(pytester: Pytester):
44+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
4245
pytester.makepyfile(
4346
dedent(
4447
"""\
@@ -57,6 +60,7 @@ async def test_is_skipped():
5760

5861

5962
def test_asyncio_auto_mode_module_level_skip(pytester: Pytester):
63+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
6064
pytester.makepyfile(
6165
dedent(
6266
"""\
@@ -74,6 +78,7 @@ async def test_is_skipped():
7478

7579

7680
def test_asyncio_auto_mode_wrong_skip_usage(pytester: Pytester):
81+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
7782
pytester.makepyfile(
7883
dedent(
7984
"""\
@@ -91,6 +96,7 @@ async def test_is_skipped():
9196

9297

9398
def test_unittest_skiptest_compatibility(pytester: Pytester):
99+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
94100
pytester.makepyfile(
95101
dedent(
96102
"""\
@@ -108,6 +114,7 @@ async def test_is_skipped():
108114

109115

110116
def test_skip_in_module_does_not_skip_package(pytester: Pytester):
117+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
111118
pytester.makepyfile(
112119
__init__="",
113120
test_skip=dedent(

0 commit comments

Comments
 (0)