Skip to content

Commit 927d608

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 9c2e121 commit 927d608

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tests/test_exceptions.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@
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+
814
# PySide6 is automatically captures exceptions during the event loop,
915
# and re-raises them when control gets back to Python, so the related
1016
# functionality does not work, nor is needed for the end user.
1117
exception_capture_pyside6 = pytest.mark.skipif(
12-
qt_api.pytest_qt_api == "pyside6",
18+
has_pyside6_exception_capture(),
1319
reason="pytest-qt capture not working/needed on PySide6",
1420
)
1521

@@ -51,7 +57,7 @@ def test_exceptions(qtbot):
5157
)
5258
result = testdir.runpytest()
5359
if raise_error:
54-
if qt_api.pytest_qt_api == "pyside6":
60+
if has_pyside6_exception_capture():
5561
# PySide6 automatically captures exceptions during the event loop,
5662
# and re-raises them when control gets back to Python.
5763
# This results in the exception not being captured by

0 commit comments

Comments
 (0)