Skip to content

Commit ebb19e2

Browse files
committed
Add a simple example of a parametrized test, ref. #43
1 parent 6835cf4 commit ebb19e2

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/test_03_param.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,38 @@
44
import pytest
55

66

7+
def test_simple_params(ctestdir):
8+
"""Simple test for a dependency on a parametrized test.
9+
10+
This example has been used in the discussion of PR #43.
11+
"""
12+
ctestdir.makepyfile("""
13+
import pytest
14+
15+
_md = pytest.mark.dependency
16+
17+
@pytest.mark.parametrize("x", [ 0, 1 ])
18+
@pytest.mark.dependency()
19+
def test_a(x):
20+
assert x == 0
21+
22+
@pytest.mark.parametrize("x", [
23+
pytest.param(0, marks=_md(depends=["test_a[0]"])),
24+
pytest.param(1, marks=_md(depends=["test_a[1]"])),
25+
])
26+
def test_b(x):
27+
pass
28+
""")
29+
result = ctestdir.runpytest("--verbose")
30+
result.assert_outcomes(passed=2, skipped=1, failed=1)
31+
result.stdout.re_match_lines(r"""
32+
.*::test_a\[0\] PASSED
33+
.*::test_a\[1\] FAILED
34+
.*::test_b\[0\] PASSED
35+
.*::test_b\[1\] SKIPPED(?:\s+\(.*\))?
36+
""")
37+
38+
739
def test_multiple(ctestdir):
840
ctestdir.makepyfile("""
941
import pytest

0 commit comments

Comments
 (0)