-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
exceptions raised inside QtVirtual methods now make tests fail
fixes #11
- Loading branch information
1 parent
7b0a65a
commit d1fd7c0
Showing
2 changed files
with
72 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import pytest | ||
from pytestqt.qt_compat import QtGui, Qt, QtCore | ||
|
||
|
||
class Receiver(QtCore.QObject): | ||
|
||
def __init__(self, raise_error, *args, **kwargs): | ||
QtCore.QObject.__init__(self, *args, **kwargs) | ||
self._raise_error = raise_error | ||
|
||
|
||
def event(self, ev): | ||
if self._raise_error: | ||
raise ValueError('mistakes were made') | ||
return QtCore.QObject.event(self, ev) | ||
|
||
|
||
@pytest.mark.parametrize('raise_error', [False, pytest.mark.xfail(True)]) | ||
def test_catch_exceptions_in_virtual_methods(qtbot, raise_error): | ||
""" | ||
Catch exceptions that happen inside Qt virtual methods and make the | ||
tests fail if any. | ||
""" | ||
v = Receiver(raise_error) | ||
app = QtGui.QApplication.instance() | ||
app.sendEvent(v, QtCore.QEvent(QtCore.QEvent.User)) | ||
app.sendEvent(v, QtCore.QEvent(QtCore.QEvent.User)) | ||
app.processEvents() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters