Skip to content

Commit 06c1780

Browse files
committed
Add test for subtest skip
1 parent 0411e6b commit 06c1780

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

testing/test_subtests.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,31 @@ def test_foo(self):
479479
result = pytester.runpytest()
480480
result.stdout.fnmatch_lines(["* 1 passed in *"])
481481

482+
def test_non_subtest_skip(
483+
self, pytester: pytest.Pytester, monkeypatch: pytest.MonkeyPatch
484+
) -> None:
485+
monkeypatch.setenv("COLUMNS", "120")
486+
pytester.makepyfile(
487+
"""
488+
from unittest import TestCase, main
489+
490+
class T(TestCase):
491+
492+
def test_foo(self):
493+
with self.subTest(msg="subtest"):
494+
assert False, "failed subtest"
495+
self.skipTest('non-subtest skip')
496+
"""
497+
)
498+
# This output might change #13756.
499+
result = pytester.runpytest()
500+
result.stdout.fnmatch_lines(
501+
[
502+
"SUBFAILED[[]subtest[]] test_non_subtest_skip.py::T::test_foo*",
503+
"* 1 failed, 1 skipped in *",
504+
]
505+
)
506+
482507
def test_xfail(
483508
self,
484509
pytester: pytest.Pytester,

0 commit comments

Comments
 (0)