Skip to content

Commit 1ae658a

Browse files
committed
Use a custom-exception handler instead of skipping test_no_capture on PyQt5
1 parent ce0c226 commit 1ae658a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pytestqt/_tests/test_exceptions.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ def test_format_captured_exceptions():
5858

5959

6060
@pytest.mark.parametrize('no_capture_by_marker', [True, False])
61-
@pytest.mark.skipif(QT_API == 'pyqt5', reason='non captured exceptions on PyQt'
62-
' 5.5+ crash the interpreter.')
6361
def test_no_capture(testdir, no_capture_by_marker):
6462
"""
6563
Make sure options that disable exception capture are working (either marker
@@ -77,8 +75,12 @@ def test_no_capture(testdir, no_capture_by_marker):
7775
''')
7876
testdir.makepyfile('''
7977
import pytest
78+
import sys
8079
from pytestqt.qt_compat import QWidget, QtCore
8180
81+
# PyQt 5.5+ will crash if there's no custom exception handler installed
82+
sys.excepthook = lambda *args: None
83+
8284
class MyWidget(QWidget):
8385
8486
def mouseReleaseEvent(self, ev):
@@ -90,8 +92,8 @@ def test_widget(qtbot):
9092
qtbot.addWidget(w)
9193
qtbot.mouseClick(w, QtCore.Qt.LeftButton)
9294
'''.format(marker_code=marker_code))
93-
res = testdir.inline_run()
94-
res.assertoutcome(passed=1)
95+
res = testdir.runpytest()
96+
res.stdout.fnmatch_lines(['*1 passed*'])
9597

9698

9799
def test_exception_capture_on_teardown(testdir):

0 commit comments

Comments
 (0)