-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
102 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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.fnmatch_lines(""" | ||
*::test_d SKIPPED | ||
""") | ||
|
||
|
||
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.fnmatch_lines(""" | ||
*::test_d PASSED | ||
""") |