Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix potential off by one error #139

Merged
merged 6 commits into from
Jul 17, 2024
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
nicoddemus marked this conversation as resolved.
Show resolved Hide resolved
"""
)
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
Loading