Skip to content

Commit

Permalink
Fix off by one error when using -x (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhoban13 authored Jul 17, 2024
1 parent cbff3e1 commit c02c55e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
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

0 comments on commit c02c55e

Please sign in to comment.