Skip to content

Commit 81c5032

Browse files
committed
[test] Run some tests in a Pytester subprocess to avoid PytestAssertRewriteWarning.
Signed-off-by: Michael Seifert <[email protected]>
1 parent b77bff4 commit 81c5032

8 files changed

+25
-25
lines changed

tests/hypothesis/test_base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async def test_mark_inner(n):
2323
"""
2424
)
2525
)
26-
result = pytester.runpytest("--asyncio-mode=strict", "-W default")
26+
result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W default")
2727
result.assert_outcomes(passed=1)
2828

2929

@@ -67,7 +67,7 @@ async def test_explicit_fixture_request(event_loop, n):
6767
"""
6868
)
6969
)
70-
result = pytester.runpytest("--asyncio-mode=strict", "-W default")
70+
result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W default")
7171
result.assert_outcomes(passed=1, warnings=2)
7272
result.stdout.fnmatch_lines(
7373
[

tests/markers/test_function_scope.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async def test_remember_loop(event_loop):
4343
"""
4444
)
4545
)
46-
result = pytester.runpytest("--asyncio-mode=strict", "-W default")
46+
result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W default")
4747
result.assert_outcomes(passed=1, warnings=1)
4848
result.stdout.fnmatch_lines(
4949
'*is asynchronous and explicitly requests the "event_loop" fixture*'

tests/markers/test_module_scope.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def sample_fixture():
4848
"""
4949
)
5050
)
51-
result = pytester.runpytest("--asyncio-mode=strict", "-W default")
51+
result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W default")
5252
result.assert_outcomes(passed=2, warnings=2)
5353
result.stdout.fnmatch_lines(
5454
'*is asynchronous and explicitly requests the "event_loop" fixture*'

tests/modes/test_strict_mode.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ async def test_anything():
7979
"""
8080
)
8181
)
82-
result = testdir.runpytest("--asyncio-mode=strict", "-W default")
82+
result = testdir.runpytest_subprocess("--asyncio-mode=strict", "-W default")
8383
result.assert_outcomes(skipped=1, warnings=1)
8484
result.stdout.fnmatch_lines(["*async def functions are not natively supported*"])
8585

@@ -100,7 +100,7 @@ async def test_anything(any_fixture):
100100
"""
101101
)
102102
)
103-
result = testdir.runpytest("--asyncio-mode=strict", "-W default")
103+
result = testdir.runpytest_subprocess("--asyncio-mode=strict", "-W default")
104104
result.assert_outcomes(skipped=1, warnings=2)
105105
result.stdout.fnmatch_lines(
106106
[

tests/test_asyncio_mark.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_a():
1515
"""
1616
)
1717
)
18-
result = pytester.runpytest("--asyncio-mode=strict", "-W default")
18+
result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W default")
1919
result.assert_outcomes(passed=1)
2020
result.stdout.fnmatch_lines(
2121
["*is marked with '@pytest.mark.asyncio' but it is not an async function.*"]
@@ -36,7 +36,7 @@ async def test_a():
3636
"""
3737
)
3838
)
39-
result = pytester.runpytest("--asyncio-mode=strict", "-W default")
39+
result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W default")
4040
result.assert_outcomes(xfailed=1, warnings=1)
4141
result.stdout.fnmatch_lines(
4242
["*Tests based on asynchronous generators are not supported*"]
@@ -54,7 +54,7 @@ async def test_a():
5454
"""
5555
)
5656
)
57-
result = pytester.runpytest("--asyncio-mode=auto", "-W default")
57+
result = pytester.runpytest_subprocess("--asyncio-mode=auto", "-W default")
5858
result.assert_outcomes(xfailed=1, warnings=1)
5959
result.stdout.fnmatch_lines(
6060
["*Tests based on asynchronous generators are not supported*"]
@@ -76,7 +76,7 @@ async def test_a(self):
7676
"""
7777
)
7878
)
79-
result = pytester.runpytest("--asyncio-mode=strict", "-W default")
79+
result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W default")
8080
result.assert_outcomes(xfailed=1, warnings=1)
8181
result.stdout.fnmatch_lines(
8282
["*Tests based on asynchronous generators are not supported*"]
@@ -96,7 +96,7 @@ async def test_a():
9696
"""
9797
)
9898
)
99-
result = pytester.runpytest("--asyncio-mode=auto", "-W default")
99+
result = pytester.runpytest_subprocess("--asyncio-mode=auto", "-W default")
100100
result.assert_outcomes(xfailed=1, warnings=1)
101101
result.stdout.fnmatch_lines(
102102
["*Tests based on asynchronous generators are not supported*"]
@@ -119,7 +119,7 @@ async def test_a():
119119
"""
120120
)
121121
)
122-
result = pytester.runpytest("--asyncio-mode=strict", "-W default")
122+
result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W default")
123123
result.assert_outcomes(xfailed=1, warnings=1)
124124
result.stdout.fnmatch_lines(
125125
["*Tests based on asynchronous generators are not supported*"]
@@ -139,7 +139,7 @@ async def test_a():
139139
"""
140140
)
141141
)
142-
result = pytester.runpytest("--asyncio-mode=auto", "-W default")
142+
result = pytester.runpytest_subprocess("--asyncio-mode=auto", "-W default")
143143
result.assert_outcomes(xfailed=1, warnings=1)
144144
result.stdout.fnmatch_lines(
145145
["*Tests based on asynchronous generators are not supported*"]

tests/test_event_loop_fixture_finalizer.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ async def test_async_with_explicit_fixture_request(event_loop):
8484
"""
8585
)
8686
)
87-
result = pytester.runpytest("--asyncio-mode=strict", "-W default")
87+
result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W default")
8888
result.assert_outcomes(passed=1, warnings=1)
8989
result.stdout.fnmatch_lines(
9090
'*is asynchronous and explicitly requests the "event_loop" fixture*'
@@ -113,7 +113,7 @@ async def test_ends_with_unclosed_loop():
113113
"""
114114
)
115115
)
116-
result = pytester.runpytest("--asyncio-mode=strict", "-W", "default")
116+
result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W", "default")
117117
result.assert_outcomes(passed=1, warnings=2)
118118
result.stdout.fnmatch_lines("*unclosed event loop*")
119119

@@ -135,6 +135,6 @@ async def test_ends_with_unclosed_loop():
135135
"""
136136
)
137137
)
138-
result = pytester.runpytest("--asyncio-mode=strict", "-W", "default")
138+
result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W", "default")
139139
result.assert_outcomes(passed=1, warnings=1)
140140
result.stdout.fnmatch_lines("*unclosed event loop*")

tests/test_event_loop_fixture_override_deprecation.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async def test_emits_warning():
2222
"""
2323
)
2424
)
25-
result = pytester.runpytest("--asyncio-mode=strict", "-W default")
25+
result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W default")
2626
result.assert_outcomes(passed=1, warnings=1)
2727
result.stdout.fnmatch_lines(
2828
["*event_loop fixture provided by pytest-asyncio has been redefined*"]
@@ -50,7 +50,7 @@ async def test_emits_warning_when_requested_explicitly(event_loop):
5050
"""
5151
)
5252
)
53-
result = pytester.runpytest("--asyncio-mode=strict", "-W default")
53+
result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W default")
5454
result.assert_outcomes(passed=1, warnings=2)
5555
result.stdout.fnmatch_lines(
5656
["*event_loop fixture provided by pytest-asyncio has been redefined*"]
@@ -80,7 +80,7 @@ def test_emits_no_warning():
8080
"""
8181
)
8282
)
83-
result = pytester.runpytest("--asyncio-mode=strict")
83+
result = pytester.runpytest_subprocess("--asyncio-mode=strict")
8484
result.assert_outcomes(passed=1, warnings=0)
8585

8686

@@ -107,5 +107,5 @@ def test_emits_warning(uses_event_loop):
107107
"""
108108
)
109109
)
110-
result = pytester.runpytest("--asyncio-mode=strict", "-W default")
110+
result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W default")
111111
result.assert_outcomes(passed=1, warnings=1)

tests/test_explicit_event_loop_fixture_request.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async def test_coroutine_emits_warning(event_loop):
1717
"""
1818
)
1919
)
20-
result = pytester.runpytest("--asyncio-mode=strict", "-W default")
20+
result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W default")
2121
result.assert_outcomes(passed=1, warnings=1)
2222
result.stdout.fnmatch_lines(
2323
['*is asynchronous and explicitly requests the "event_loop" fixture*']
@@ -39,7 +39,7 @@ async def test_coroutine_emits_warning(self, event_loop):
3939
"""
4040
)
4141
)
42-
result = pytester.runpytest("--asyncio-mode=strict", "-W default")
42+
result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W default")
4343
result.assert_outcomes(passed=1, warnings=1)
4444
result.stdout.fnmatch_lines(
4545
['*is asynchronous and explicitly requests the "event_loop" fixture*']
@@ -62,7 +62,7 @@ async def test_coroutine_emits_warning(event_loop):
6262
"""
6363
)
6464
)
65-
result = pytester.runpytest("--asyncio-mode=strict", "-W default")
65+
result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W default")
6666
result.assert_outcomes(passed=1, warnings=1)
6767
result.stdout.fnmatch_lines(
6868
['*is asynchronous and explicitly requests the "event_loop" fixture*']
@@ -88,7 +88,7 @@ async def test_uses_fixture(emits_warning):
8888
"""
8989
)
9090
)
91-
result = pytester.runpytest("--asyncio-mode=strict", "-W default")
91+
result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W default")
9292
result.assert_outcomes(passed=1, warnings=1)
9393
result.stdout.fnmatch_lines(
9494
['*is asynchronous and explicitly requests the "event_loop" fixture*']
@@ -114,7 +114,7 @@ async def test_uses_fixture(emits_warning):
114114
"""
115115
)
116116
)
117-
result = pytester.runpytest("--asyncio-mode=strict", "-W default")
117+
result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W default")
118118
result.assert_outcomes(passed=1, warnings=1)
119119
result.stdout.fnmatch_lines(
120120
['*is asynchronous and explicitly requests the "event_loop" fixture*']

0 commit comments

Comments
 (0)