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