Skip to content

Commit ed5668a

Browse files
authored
Fix test_exceptions_dont_leak in Python 3.12 (#535)
Fixes #532
1 parent 36a436d commit ed5668a

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
UNRELEASED
2+
----------
3+
4+
- Fixed exception handling so they are properly cleared in Python 3.12, due to the new `sys.last_exc <https://docs.python.org/3/library/sys.html#sys.last_exc>`__ attribute (`#532`_).
5+
6+
.. _#532: https://github.com/pytest-dev/pytest-qt/issues/532
7+
18
4.3.1 (2023-12-22)
29
------------------
310

src/pytestqt/exceptions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def fail_if_exceptions_occurred(self, when):
6565
prefix = "%s ERROR: " % when
6666
msg = prefix + format_captured_exceptions(exceptions)
6767
del exceptions[:] # Don't keep exceptions alive longer.
68+
if hasattr(sys, "last_exc"):
69+
sys.last_exc = None
6870
pytest.fail(msg, pytrace=False)
6971

7072

tests/test_exceptions.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,6 @@ def event(self, ev):
365365

366366

367367
@exception_capture_pyside6
368-
@pytest.mark.skipif(
369-
sys.version_info[:2] == (3, 12), reason="#532 requires investigation"
370-
)
371368
def test_exceptions_dont_leak(testdir):
372369
"""
373370
Ensure exceptions are cleared when an exception occurs and don't leak (#187).

0 commit comments

Comments
 (0)