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 :
2
7
"""Verify that fixtures are not executed."""
3
- testdir .makepyfile (
8
+ pytester .makepyfile (
4
9
"""
5
10
import pytest
6
11
@pytest.fixture
@@ -11,15 +16,17 @@ def test_arg(arg):
11
16
"""
12
17
)
13
18
14
- result = testdir .runpytest ("--setup-plan" )
19
+ result = pytester .runpytest ("--setup-plan" )
15
20
assert result .ret == 0
16
21
17
22
result .stdout .fnmatch_lines (
18
23
["*SETUP F arg*" , "*test_arg (fixtures used: arg)" , "*TEARDOWN F arg*" ]
19
24
)
20
25
21
26
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 :
23
30
"""Verify that when a fixture lives for longer than a single test, --setup-plan
24
31
correctly displays the SETUP/TEARDOWN indicators the right number of times.
25
32
@@ -31,7 +38,7 @@ def test_show_multi_test_fixture_setup_and_teardown_correctly_simple(testdir):
31
38
correct fixture lifetimes. It was purely a display bug for --setup-plan, and
32
39
did not affect the related --setup-show or --setup-only.)
33
40
"""
34
- testdir .makepyfile (
41
+ pytester .makepyfile (
35
42
"""
36
43
import pytest
37
44
@pytest.fixture(scope = 'class')
@@ -45,7 +52,7 @@ def test_two(self, fix):
45
52
"""
46
53
)
47
54
48
- result = testdir .runpytest ("--setup-plan" )
55
+ result = pytester .runpytest ("--setup-plan" )
49
56
assert result .ret == 0
50
57
51
58
setup_fragment = "SETUP C fix"
@@ -66,9 +73,11 @@ def test_two(self, fix):
66
73
assert teardown_count == 1
67
74
68
75
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 :
70
79
"""Verify that SETUP/TEARDOWN messages match what comes out of --setup-show."""
71
- testdir .makepyfile (
80
+ pytester .makepyfile (
72
81
"""
73
82
import pytest
74
83
@pytest.fixture(scope = 'session')
@@ -93,8 +102,8 @@ def test_two(self, sess, mod, cls, func):
93
102
"""
94
103
)
95
104
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" )
98
107
99
108
# the number and text of these lines should be identical
100
109
plan_lines = [
0 commit comments