@@ -36,8 +36,9 @@ def test_d():
36
36
*::test_d PASSED
37
37
""" )
38
38
39
+
39
40
def test_skip_depend (ctestdir ):
40
- """One test is skipped, other depending tests are skipped as well.
41
+ """One test is skipped, other dependent tests are skipped as well.
41
42
This also includes indirect dependencies.
42
43
"""
43
44
ctestdir .makepyfile ("""
@@ -70,7 +71,7 @@ def test_d():
70
71
71
72
72
73
def test_fail_depend (ctestdir ):
73
- """One test fails, other depending tests are skipped.
74
+ """One test fails, other dependent tests are skipped.
74
75
This also includes indirect dependencies.
75
76
"""
76
77
ctestdir .makepyfile ("""
@@ -132,3 +133,71 @@ def test_d():
132
133
*::test_c SKIPPED
133
134
*::test_d SKIPPED
134
135
""" )
136
+
137
+
138
+ def test_explicit_select (ctestdir ):
139
+ """Explicitly select only a single test that depends on another one.
140
+
141
+ Since the other test has not been run at all, the selected test
142
+ will be skipped.
143
+ """
144
+ ctestdir .makepyfile ("""
145
+ import pytest
146
+
147
+ @pytest.mark.dependency()
148
+ def test_a():
149
+ pass
150
+
151
+ @pytest.mark.dependency()
152
+ def test_b():
153
+ pass
154
+
155
+ @pytest.mark.dependency()
156
+ def test_c():
157
+ pass
158
+
159
+ @pytest.mark.dependency(depends=["test_c"])
160
+ def test_d():
161
+ pass
162
+ """ )
163
+ result = ctestdir .runpytest ("--verbose" , "test_explicit_select.py::test_d" )
164
+ result .assert_outcomes (passed = 0 , skipped = 1 , failed = 0 )
165
+ result .stdout .fnmatch_lines ("""
166
+ *::test_d SKIPPED
167
+ """ )
168
+
169
+
170
+ def test_depend_unknown (ctestdir ):
171
+ """Depend on an unknown test that is not even defined in the test set.
172
+
173
+ Note that is not an error to depend on an undefined test, but the
174
+ dependent test will be skipped since the non-existent dependency
175
+ has not been run successfully.
176
+ """
177
+ ctestdir .makepyfile ("""
178
+ import pytest
179
+
180
+ @pytest.mark.dependency()
181
+ def test_a():
182
+ pass
183
+
184
+ @pytest.mark.dependency()
185
+ def test_b():
186
+ pass
187
+
188
+ @pytest.mark.dependency()
189
+ def test_c():
190
+ pass
191
+
192
+ @pytest.mark.dependency(depends=["test_x"])
193
+ def test_d():
194
+ pass
195
+ """ )
196
+ result = ctestdir .runpytest ("--verbose" )
197
+ result .assert_outcomes (passed = 3 , skipped = 1 , failed = 0 )
198
+ result .stdout .fnmatch_lines ("""
199
+ *::test_a PASSED
200
+ *::test_b PASSED
201
+ *::test_c PASSED
202
+ *::test_d SKIPPED
203
+ """ )
0 commit comments