Skip to content

Commit 06e39e9

Browse files
committed
Add another two tests featuring unknown dependencies.
1 parent 9913d2a commit 06e39e9

File tree

1 file changed

+71
-2
lines changed

1 file changed

+71
-2
lines changed

tests/test_02_simple_dependency.py

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ def test_d():
3636
*::test_d PASSED
3737
""")
3838

39+
3940
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.
4142
This also includes indirect dependencies.
4243
"""
4344
ctestdir.makepyfile("""
@@ -70,7 +71,7 @@ def test_d():
7071

7172

7273
def test_fail_depend(ctestdir):
73-
"""One test fails, other depending tests are skipped.
74+
"""One test fails, other dependent tests are skipped.
7475
This also includes indirect dependencies.
7576
"""
7677
ctestdir.makepyfile("""
@@ -132,3 +133,71 @@ def test_d():
132133
*::test_c SKIPPED
133134
*::test_d SKIPPED
134135
""")
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

Comments
 (0)