Skip to content

Commit 6a5037a

Browse files
pytest-dev#7942 test_setupplan.py migrate from testdir to Pytester (pytest-dev#8004)
Co-authored-by: Bruno Oliveira <[email protected]>
1 parent 30287b4 commit 6a5037a

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ Florian Bruhin
109109
Florian Dahlitz
110110
Floris Bruynooghe
111111
Gabriel Reis
112+
Garvit Shubham
112113
Gene Wood
113114
George Kussumoto
114115
Georgy Dyuldin

testing/test_setupplan.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
def test_show_fixtures_and_test(testdir, dummy_yaml_custom_test):
1+
from _pytest.pytester import Pytester
2+
3+
4+
def test_show_fixtures_and_test(
5+
pytester: Pytester, dummy_yaml_custom_test: None
6+
) -> None:
27
"""Verify that fixtures are not executed."""
3-
testdir.makepyfile(
8+
pytester.makepyfile(
49
"""
510
import pytest
611
@pytest.fixture
@@ -11,15 +16,17 @@ def test_arg(arg):
1116
"""
1217
)
1318

14-
result = testdir.runpytest("--setup-plan")
19+
result = pytester.runpytest("--setup-plan")
1520
assert result.ret == 0
1621

1722
result.stdout.fnmatch_lines(
1823
["*SETUP F arg*", "*test_arg (fixtures used: arg)", "*TEARDOWN F arg*"]
1924
)
2025

2126

22-
def test_show_multi_test_fixture_setup_and_teardown_correctly_simple(testdir):
27+
def test_show_multi_test_fixture_setup_and_teardown_correctly_simple(
28+
pytester: Pytester,
29+
) -> None:
2330
"""Verify that when a fixture lives for longer than a single test, --setup-plan
2431
correctly displays the SETUP/TEARDOWN indicators the right number of times.
2532
@@ -31,7 +38,7 @@ def test_show_multi_test_fixture_setup_and_teardown_correctly_simple(testdir):
3138
correct fixture lifetimes. It was purely a display bug for --setup-plan, and
3239
did not affect the related --setup-show or --setup-only.)
3340
"""
34-
testdir.makepyfile(
41+
pytester.makepyfile(
3542
"""
3643
import pytest
3744
@pytest.fixture(scope = 'class')
@@ -45,7 +52,7 @@ def test_two(self, fix):
4552
"""
4653
)
4754

48-
result = testdir.runpytest("--setup-plan")
55+
result = pytester.runpytest("--setup-plan")
4956
assert result.ret == 0
5057

5158
setup_fragment = "SETUP C fix"
@@ -66,9 +73,11 @@ def test_two(self, fix):
6673
assert teardown_count == 1
6774

6875

69-
def test_show_multi_test_fixture_setup_and_teardown_same_as_setup_show(testdir):
76+
def test_show_multi_test_fixture_setup_and_teardown_same_as_setup_show(
77+
pytester: Pytester,
78+
) -> None:
7079
"""Verify that SETUP/TEARDOWN messages match what comes out of --setup-show."""
71-
testdir.makepyfile(
80+
pytester.makepyfile(
7281
"""
7382
import pytest
7483
@pytest.fixture(scope = 'session')
@@ -93,8 +102,8 @@ def test_two(self, sess, mod, cls, func):
93102
"""
94103
)
95104

96-
plan_result = testdir.runpytest("--setup-plan")
97-
show_result = testdir.runpytest("--setup-show")
105+
plan_result = pytester.runpytest("--setup-plan")
106+
show_result = pytester.runpytest("--setup-show")
98107

99108
# the number and text of these lines should be identical
100109
plan_lines = [

0 commit comments

Comments
 (0)