Skip to content

Commit 73a5402

Browse files
committed
Add test case for nested subtests
1 parent 5c0611c commit 73a5402

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

testing/test_subtests.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,3 +975,29 @@ def test2(): pass
975975
"* 1 failed in *",
976976
]
977977
)
978+
979+
980+
def test_nested(pytester: pytest.Pytester) -> None:
981+
"""
982+
Currently we do nothing special with nested subtests.
983+
984+
This test only sediments how they work now, we might reconsider adding some kind of nesting support in the future.
985+
"""
986+
pytester.makepyfile(
987+
"""
988+
import pytest
989+
def test(subtests):
990+
with subtests.test("a"):
991+
with subtests.test("b"):
992+
assert False, "b failed"
993+
assert False, "a failed"
994+
"""
995+
)
996+
result = pytester.runpytest_subprocess()
997+
result.stdout.fnmatch_lines(
998+
[
999+
"[b] SUBFAILED test_nested.py::test - AssertionError: b failed",
1000+
"[a] SUBFAILED test_nested.py::test - AssertionError: a failed",
1001+
"* 3 failed in *",
1002+
]
1003+
)

0 commit comments

Comments
 (0)