Skip to content

Commit ea5e8ef

Browse files
test: add pytest config to isolated test directories
- Add pytester.makeini() calls to ensure asyncio_default_fixture_loop_scope is properly configured in test directories
1 parent 22fa51c commit ea5e8ef

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

tests/markers/test_invalid_arguments.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
def test_no_error_when_scope_passed_as_sole_keyword_argument(
99
pytester: pytest.Pytester,
1010
):
11+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
1112
pytester.makepyfile(
1213
dedent(
1314
"""\
@@ -27,6 +28,7 @@ async def test_anything():
2728
def test_error_when_scope_passed_as_positional_argument(
2829
pytester: pytest.Pytester,
2930
):
31+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
3032
pytester.makepyfile(
3133
dedent(
3234
"""\
@@ -48,6 +50,7 @@ async def test_anything():
4850
def test_error_when_wrong_keyword_argument_is_passed(
4951
pytester: pytest.Pytester,
5052
):
53+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
5154
pytester.makepyfile(
5255
dedent(
5356
"""\
@@ -69,6 +72,7 @@ async def test_anything():
6972
def test_error_when_additional_keyword_arguments_are_passed(
7073
pytester: pytest.Pytester,
7174
):
75+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
7276
pytester.makepyfile(
7377
dedent(
7478
"""\

tests/test_asyncio_mark.py

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

77

88
def test_asyncio_mark_on_sync_function_emits_warning(pytester: Pytester):
9+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
910
pytester.makepyfile(
1011
dedent(
1112
"""\
@@ -27,6 +28,7 @@ def test_a():
2728
def test_asyncio_mark_on_async_generator_function_emits_warning_in_strict_mode(
2829
pytester: Pytester,
2930
):
31+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
3032
pytester.makepyfile(
3133
dedent(
3234
"""\
@@ -48,6 +50,7 @@ async def test_a():
4850
def test_asyncio_mark_on_async_generator_function_emits_warning_in_auto_mode(
4951
pytester: Pytester,
5052
):
53+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
5154
pytester.makepyfile(
5255
dedent(
5356
"""\
@@ -66,6 +69,7 @@ async def test_a():
6669
def test_asyncio_mark_on_async_generator_method_emits_warning_in_strict_mode(
6770
pytester: Pytester,
6871
):
72+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
6973
pytester.makepyfile(
7074
dedent(
7175
"""\
@@ -88,6 +92,7 @@ async def test_a(self):
8892
def test_asyncio_mark_on_async_generator_method_emits_warning_in_auto_mode(
8993
pytester: Pytester,
9094
):
95+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
9196
pytester.makepyfile(
9297
dedent(
9398
"""\
@@ -108,6 +113,7 @@ async def test_a():
108113
def test_asyncio_mark_on_async_generator_staticmethod_emits_warning_in_strict_mode(
109114
pytester: Pytester,
110115
):
116+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
111117
pytester.makepyfile(
112118
dedent(
113119
"""\
@@ -131,6 +137,7 @@ async def test_a():
131137
def test_asyncio_mark_on_async_generator_staticmethod_emits_warning_in_auto_mode(
132138
pytester: Pytester,
133139
):
140+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
134141
pytester.makepyfile(
135142
dedent(
136143
"""\

tests/test_event_loop_fixture.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77

88
def test_event_loop_fixture_respects_event_loop_policy(pytester: Pytester):
9+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
910
pytester.makeconftest(
1011
dedent(
1112
"""\

tests/test_fixture_loop_scopes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def test_loop_scope_session_is_independent_of_fixture_scope(
1313
pytester: Pytester,
1414
fixture_scope: str,
1515
):
16+
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
1617
pytester.makepyfile(
1718
dedent(
1819
f"""\

0 commit comments

Comments
 (0)