Skip to content

Commit 9a85da9

Browse files
committed
Replace pytester with older testdir fixture
1 parent cea853a commit 9a85da9

File tree

5 files changed

+51
-49
lines changed

5 files changed

+51
-49
lines changed

tests/hypothesis/test_base.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import pytest
88
from hypothesis import given, strategies as st
99

10+
pytest_plugins = "testdir"
11+
1012

1113
@pytest.fixture(scope="module")
1214
def event_loop():
@@ -43,8 +45,8 @@ async def test_can_use_fixture_provided_event_loop(event_loop, n):
4345
await semaphore.acquire()
4446

4547

46-
def test_async_auto_marked(pytester):
47-
pytester.makepyfile(
48+
def test_async_auto_marked(testdir):
49+
testdir.makepyfile(
4850
dedent(
4951
"""\
5052
import asyncio
@@ -60,13 +62,13 @@ async def test_hypothesis(n: int):
6062
"""
6163
)
6264
)
63-
result = pytester.runpytest("--asyncio-mode=auto")
65+
result = testdir.runpytest("--asyncio-mode=auto")
6466
result.assert_outcomes(passed=1)
6567

6668

67-
def test_sync_not_auto_marked(pytester):
69+
def test_sync_not_auto_marked(testdir):
6870
"""Assert that synchronous Hypothesis functions are not marked with asyncio"""
69-
pytester.makepyfile(
71+
testdir.makepyfile(
7072
dedent(
7173
"""\
7274
import asyncio
@@ -84,5 +86,5 @@ def test_hypothesis(request, n: int):
8486
"""
8587
)
8688
)
87-
result = pytester.runpytest("--asyncio-mode=auto")
89+
result = testdir.runpytest("--asyncio-mode=auto")
8890
result.assert_outcomes(passed=1)

tests/modes/test_auto_mode.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from textwrap import dedent
22

3-
pytest_plugins = "pytester"
3+
pytest_plugins = "testdir"
44

55

6-
def test_auto_mode_cmdline(pytester):
7-
pytester.makepyfile(
6+
def test_auto_mode_cmdline(testdir):
7+
testdir.makepyfile(
88
dedent(
99
"""\
1010
import asyncio
@@ -17,12 +17,12 @@ async def test_a():
1717
"""
1818
)
1919
)
20-
result = pytester.runpytest("--asyncio-mode=auto")
20+
result = testdir.runpytest("--asyncio-mode=auto")
2121
result.assert_outcomes(passed=1)
2222

2323

24-
def test_auto_mode_cfg(pytester):
25-
pytester.makepyfile(
24+
def test_auto_mode_cfg(testdir):
25+
testdir.makepyfile(
2626
dedent(
2727
"""\
2828
import asyncio
@@ -35,13 +35,13 @@ async def test_a():
3535
"""
3636
)
3737
)
38-
pytester.makefile(".ini", pytest="[pytest]\nasyncio_mode = auto\n")
39-
result = pytester.runpytest()
38+
testdir.makefile(".ini", pytest="[pytest]\nasyncio_mode = auto\n")
39+
result = testdir.runpytest()
4040
result.assert_outcomes(passed=1)
4141

4242

43-
def test_auto_mode_async_fixture(pytester):
44-
pytester.makepyfile(
43+
def test_auto_mode_async_fixture(testdir):
44+
testdir.makepyfile(
4545
dedent(
4646
"""\
4747
import asyncio
@@ -60,12 +60,12 @@ async def test_a(fixture_a):
6060
"""
6161
)
6262
)
63-
result = pytester.runpytest("--asyncio-mode=auto")
63+
result = testdir.runpytest("--asyncio-mode=auto")
6464
result.assert_outcomes(passed=1)
6565

6666

67-
def test_auto_mode_method_fixture(pytester):
68-
pytester.makepyfile(
67+
def test_auto_mode_method_fixture(testdir):
68+
testdir.makepyfile(
6969
dedent(
7070
"""\
7171
import asyncio
@@ -87,5 +87,5 @@ async def test_a(self, fixture_a):
8787
"""
8888
)
8989
)
90-
result = pytester.runpytest("--asyncio-mode=auto")
90+
result = testdir.runpytest("--asyncio-mode=auto")
9191
result.assert_outcomes(passed=1)

tests/modes/test_legacy_mode.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from textwrap import dedent
22

3-
pytest_plugins = "pytester"
3+
pytest_plugins = "testdir"
44

55

66
LEGACY_MODE = (
@@ -18,8 +18,8 @@
1818
).format(name="*")
1919

2020

21-
def test_warning_for_legacy_mode_cmdline(pytester):
22-
pytester.makepyfile(
21+
def test_warning_for_legacy_mode_cmdline(testdir):
22+
testdir.makepyfile(
2323
dedent(
2424
"""\
2525
import asyncio
@@ -33,13 +33,13 @@ async def test_a():
3333
"""
3434
)
3535
)
36-
result = pytester.runpytest("--asyncio-mode=legacy")
36+
result = testdir.runpytest("--asyncio-mode=legacy")
3737
assert result.parseoutcomes()["warnings"] == 1
3838
result.stdout.fnmatch_lines(["*" + LEGACY_MODE + "*"])
3939

4040

41-
def test_warning_for_legacy_mode_cfg(pytester):
42-
pytester.makepyfile(
41+
def test_warning_for_legacy_mode_cfg(testdir):
42+
testdir.makepyfile(
4343
dedent(
4444
"""\
4545
import asyncio
@@ -53,15 +53,15 @@ async def test_a():
5353
"""
5454
)
5555
)
56-
pytester.makefile(".ini", pytest="[pytest]\nasyncio_mode = legacy\n")
57-
result = pytester.runpytest()
56+
testdir.makefile(".ini", pytest="[pytest]\nasyncio_mode = legacy\n")
57+
result = testdir.runpytest()
5858
assert result.parseoutcomes()["warnings"] == 1
5959
result.stdout.fnmatch_lines(["*" + LEGACY_MODE + "*"])
6060
result.stdout.no_fnmatch_line("*" + LEGACY_ASYNCIO_FIXTURE + "*")
6161

6262

63-
def test_warning_for_legacy_fixture(pytester):
64-
pytester.makepyfile(
63+
def test_warning_for_legacy_fixture(testdir):
64+
testdir.makepyfile(
6565
dedent(
6666
"""\
6767
import asyncio
@@ -81,13 +81,13 @@ async def test_a(fixture_a):
8181
"""
8282
)
8383
)
84-
result = pytester.runpytest("--asyncio-mode=legacy")
84+
result = testdir.runpytest("--asyncio-mode=legacy")
8585
assert result.parseoutcomes()["warnings"] == 2
8686
result.stdout.fnmatch_lines(["*" + LEGACY_ASYNCIO_FIXTURE + "*"])
8787

8888

89-
def test_warning_for_legacy_method_fixture(pytester):
90-
pytester.makepyfile(
89+
def test_warning_for_legacy_method_fixture(testdir):
90+
testdir.makepyfile(
9191
dedent(
9292
"""\
9393
import asyncio
@@ -110,6 +110,6 @@ async def test_a(self, fixture_a):
110110
"""
111111
)
112112
)
113-
result = pytester.runpytest("--asyncio-mode=legacy")
113+
result = testdir.runpytest("--asyncio-mode=legacy")
114114
assert result.parseoutcomes()["warnings"] == 2
115115
result.stdout.fnmatch_lines(["*" + LEGACY_ASYNCIO_FIXTURE + "*"])

tests/modes/test_strict_mode.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from textwrap import dedent
22

3-
pytest_plugins = "pytester"
3+
pytest_plugins = "testdir"
44

55

6-
def test_strict_mode_cmdline(pytester):
7-
pytester.makepyfile(
6+
def test_strict_mode_cmdline(testdir):
7+
testdir.makepyfile(
88
dedent(
99
"""\
1010
import asyncio
@@ -18,12 +18,12 @@ async def test_a():
1818
"""
1919
)
2020
)
21-
result = pytester.runpytest("--asyncio-mode=strict")
21+
result = testdir.runpytest("--asyncio-mode=strict")
2222
result.assert_outcomes(passed=1)
2323

2424

25-
def test_strict_mode_cfg(pytester):
26-
pytester.makepyfile(
25+
def test_strict_mode_cfg(testdir):
26+
testdir.makepyfile(
2727
dedent(
2828
"""\
2929
import asyncio
@@ -37,13 +37,13 @@ async def test_a():
3737
"""
3838
)
3939
)
40-
pytester.makefile(".ini", pytest="[pytest]\nasyncio_mode = strict\n")
41-
result = pytester.runpytest()
40+
testdir.makefile(".ini", pytest="[pytest]\nasyncio_mode = strict\n")
41+
result = testdir.runpytest()
4242
result.assert_outcomes(passed=1)
4343

4444

45-
def test_strict_mode_method_fixture(pytester):
46-
pytester.makepyfile(
45+
def test_strict_mode_method_fixture(testdir):
46+
testdir.makepyfile(
4747
dedent(
4848
"""\
4949
import asyncio
@@ -66,5 +66,5 @@ async def test_a(self, fixture_a):
6666
"""
6767
)
6868
)
69-
result = pytester.runpytest("--asyncio-mode=auto")
69+
result = testdir.runpytest("--asyncio-mode=auto")
7070
result.assert_outcomes(passed=1)

tests/test_flaky_integration.py

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

55
from textwrap import dedent
66

7-
pytest_plugins = "pytester"
7+
pytest_plugins = "testdir"
88

99

10-
def test_auto_mode_cmdline(pytester):
11-
pytester.makepyfile(
10+
def test_auto_mode_cmdline(testdir):
11+
testdir.makepyfile(
1212
dedent(
1313
"""\
1414
import asyncio
@@ -29,7 +29,7 @@ async def test_asyncio_flaky_thing_that_fails_then_succeeds():
2929
)
3030
# runpytest_subprocess() is required to don't pollute the output
3131
# with flaky restart information
32-
result = pytester.runpytest_subprocess()
32+
result = testdir.runpytest_subprocess("--asyncio-mode=strict")
3333
result.assert_outcomes(passed=1)
3434
result.stdout.fnmatch_lines(
3535
[

0 commit comments

Comments
 (0)