Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
CHANGELOG
=========

UNRELEASED
----------

* Fixed bug were an extra test would execute when ``-x/--exitfirst`` was used (`#139`_).

.. _#139: https://github.com/pytest-dev/pytest-subtests/pull/139

0.13.0 (2024-07-07)
-------------------

Expand Down
6 changes: 3 additions & 3 deletions src/pytest_subtests/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,6 @@ def __exit__(
__tracebackhide__ = True
try:
if exc_val is not None:
if self.request.session.shouldfail:
return False

exc_info = ExceptionInfo.from_exception(exc_val)
else:
exc_info = None
Expand Down Expand Up @@ -275,6 +272,9 @@ def __exit__(
node=self.request.node, call=call_info, report=sub_report
)

if exc_val is not None:
if self.request.session.shouldfail:
return False
return True


Expand Down
7 changes: 4 additions & 3 deletions tests/test_subtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,15 +593,16 @@ def test_foo(subtests):
assert False

with subtests.test("sub2"):
pass
assert False
"""
)
result = pytester.runpytest("--exitfirst")
assert result.parseoutcomes()["failed"] == 1
assert result.parseoutcomes()["failed"] == 2
result.stdout.fnmatch_lines(
[
"*[[]sub1[]] SUBFAIL test_exitfirst.py::test_foo - assert False*",
"* stopping after 1 failures*",
"FAILED test_exitfirst.py::test_foo - assert False",
"* stopping after 2 failures*",
],
consecutive=True,
)
Expand Down