-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add examples on grouping tests using fixtures to advanced usage.
- Loading branch information
Showing
3 changed files
with
74 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import pytest | ||
from pytest_dependency import depends | ||
|
||
@pytest.fixture(scope="module", params=range(1,10)) | ||
def testcase(request): | ||
param = request.param | ||
return param | ||
|
||
@pytest.mark.dependency() | ||
def test_a(testcase): | ||
if testcase % 7 == 0: | ||
pytest.xfail("deliberate fail") | ||
assert False | ||
|
||
@pytest.mark.dependency() | ||
def test_b(request, testcase): | ||
depends(request, ["test_a[%d]" % testcase]) | ||
pass |
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,26 @@ | ||
import pytest | ||
from pytest_dependency import depends | ||
|
||
@pytest.fixture(scope="module", params=range(1,10)) | ||
def testcase(request): | ||
param = request.param | ||
return param | ||
|
||
@pytest.fixture(scope="module") | ||
def dep_testcase(request, testcase): | ||
depends(request, ["test_a[%d]" % testcase]) | ||
return testcase | ||
|
||
@pytest.mark.dependency() | ||
def test_a(testcase): | ||
if testcase % 7 == 0: | ||
pytest.xfail("deliberate fail") | ||
assert False | ||
|
||
@pytest.mark.dependency() | ||
def test_b(dep_testcase): | ||
pass | ||
|
||
@pytest.mark.dependency() | ||
def test_c(dep_testcase): | ||
pass |
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