File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -242,9 +242,6 @@ def __exit__(
242
242
__tracebackhide__ = True
243
243
try :
244
244
if exc_val is not None :
245
- if self .request .session .shouldfail :
246
- return False
247
-
248
245
exc_info = ExceptionInfo .from_exception (exc_val )
249
246
else :
250
247
exc_info = None
@@ -275,7 +272,9 @@ def __exit__(
275
272
node = self .request .node , call = call_info , report = sub_report
276
273
)
277
274
278
- return True
275
+ if exc_val is not None :
276
+ if self .request .session .shouldfail :
277
+ pytest .exit (reason = f"subtest failed" )
279
278
280
279
281
280
def make_call_info (
Original file line number Diff line number Diff line change @@ -593,11 +593,13 @@ def test_foo(subtests):
593
593
assert False
594
594
595
595
with subtests.test("sub2"):
596
- assert False
596
+ assert True
597
+
598
+ assert False, "This would fail the parent, but shouldn't be reached"
597
599
"""
598
600
)
599
601
result = pytester .runpytest ("--exitfirst" )
600
- assert result .parseoutcomes ()["failed" ] == 1
602
+ assert result .parseoutcomes ()["failed" ] == 1 # sub1 failed
601
603
result .stdout .fnmatch_lines (
602
604
[
603
605
"*[[]sub1[]] SUBFAIL test_exitfirst.py::test_foo - assert False*" ,
@@ -606,3 +608,4 @@ def test_foo(subtests):
606
608
consecutive = True ,
607
609
)
608
610
result .stdout .no_fnmatch_line ("*sub2*" ) # sub2 not executed.
611
+ result .stdout .no_fnmatch_line ("*This would fail the parent*" ) # parent test neither passed nor failed
You can’t perform that action at this time.
0 commit comments