Skip to content

Commit a0a45d2

Browse files
committed
tests: Fix exception capture tests with older PySide6
Follow-up to #525 to conditionally do the right thing based on the PySide6 version, so we can continue to run tests with older versions.
1 parent 9d07374 commit a0a45d2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/test_exceptions.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@
55
from pytestqt.exceptions import capture_exceptions, format_captured_exceptions
66
from pytestqt.qt_compat import qt_api
77

8+
9+
def has_pyside6_exception_capture():
10+
return qt_api.pytest_qt_api == "pyside6" and tuple(
11+
int(part) for part in qt_api.get_versions().qt_api_version.split(".")
12+
) >= (6, 5, 2)
13+
14+
815
# PySide6 is automatically captures exceptions during the event loop,
916
# and re-raises them when control gets back to Python, so the related
1017
# functionality does not work, nor is needed for the end user.
1118
exception_capture_pyside6 = pytest.mark.skipif(
12-
qt_api.pytest_qt_api == "pyside6",
19+
has_pyside6_exception_capture(),
1320
reason="pytest-qt capture not working/needed on PySide6",
1421
)
1522

@@ -51,7 +58,7 @@ def test_exceptions(qtbot):
5158
)
5259
result = testdir.runpytest()
5360
if raise_error:
54-
if qt_api.pytest_qt_api == "pyside6":
61+
if has_pyside6_exception_capture():
5562
# PySide6 automatically captures exceptions during the event loop,
5663
# and re-raises them when control gets back to Python.
5764
# This results in the exception not being captured by

0 commit comments

Comments
 (0)