forked from RKrahl/pytest-dependency
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_04_ignore_unknown.py
72 lines (57 loc) · 1.85 KB
/
test_04_ignore_unknown.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"""Test the ignore-unknown-dependency command line option.
"""
import pytest
def test_no_ignore(ctestdir):
"""No command line option, e.g. ignore-unknown-dependency is not set.
Explicitly select only a single test that depends on another one.
Since the other test has not been run at all, the selected test
will be skipped.
"""
ctestdir.makepyfile("""
import pytest
@pytest.mark.dependency()
def test_a():
pass
@pytest.mark.dependency()
def test_b():
pass
@pytest.mark.dependency()
def test_c():
pass
@pytest.mark.dependency(depends=["test_c"])
def test_d():
pass
""")
result = ctestdir.runpytest("--verbose", "test_no_ignore.py::test_d")
result.assert_outcomes(passed=0, skipped=1, failed=0)
result.stdout.re_match_lines(r"""
.*::test_d SKIPPED(?:\s+\(.*\))?
""")
def test_ignore(ctestdir):
"""Set the ignore-unknown-dependency command line option.
Explicitly select only a single test that depends on another one.
The other test has not been run at all, but since unknown
dependencies will be ignored, the selected test will be run
nevertheless.
"""
ctestdir.makepyfile("""
import pytest
@pytest.mark.dependency()
def test_a():
pass
@pytest.mark.dependency()
def test_b():
pass
@pytest.mark.dependency()
def test_c():
pass
@pytest.mark.dependency(depends=["test_c"])
def test_d():
pass
""")
result = ctestdir.runpytest("--verbose", "--ignore-unknown-dependency",
"test_ignore.py::test_d")
result.assert_outcomes(passed=1, skipped=0, failed=0)
result.stdout.re_match_lines(r"""
.*::test_d PASSED
""")