File tree 5 files changed +64
-1
lines changed
5 files changed +64
-1
lines changed Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <projectDescription >
3
+ <name >pytest-qt</name >
4
+ <comment ></comment >
5
+ <projects >
6
+ </projects >
7
+ <buildSpec >
8
+ <buildCommand >
9
+ <name >org.python.pydev.PyDevBuilder</name >
10
+ <arguments >
11
+ </arguments >
12
+ </buildCommand >
13
+ </buildSpec >
14
+ <natures >
15
+ <nature >org.python.pydev.pythonNature</nature >
16
+ </natures >
17
+ </projectDescription >
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" standalone =" no" ?>
2
+ <?eclipse-pydev version =" 1.0" ?><pydev_project >
3
+ <pydev_pathproperty name =" org.python.pydev.PROJECT_SOURCE_PATH" >
4
+ <path >/${PROJECT_DIR_NAME}</path >
5
+ </pydev_pathproperty >
6
+ <pydev_property name =" org.python.pydev.PYTHON_PROJECT_VERSION" >python 2.7</pydev_property >
7
+ <pydev_property name =" org.python.pydev.PYTHON_PROJECT_INTERPRETER" >Default</pydev_property >
8
+ </pydev_project >
Original file line number Diff line number Diff line change @@ -149,6 +149,11 @@ Many thanks to:
149
149
.. |pycharm | image :: https://www.jetbrains.com/pycharm/docs/logo_pycharm.png
150
150
:target: https://www.jetbrains.com/pycharm
151
151
152
+ .. |pydev | image :: http://www.pydev.org/images/pydev_banner3.png
153
+ :target: https://www.pydev.org
154
+
152
155
|pycharm |
153
156
157
+ |pydev |
158
+
154
159
.. _tox : http://tox.readthedocs.org
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ def start(self):
34
34
"""
35
35
def hook (type_ , value , tback ):
36
36
self .exceptions .append ((type_ , value , tback ))
37
+ sys .stderr .write (format_captured_exceptions ([(type_ , value , tback )]))
37
38
38
39
self .old_hook = sys .excepthook
39
40
sys .excepthook = hook
Original file line number Diff line number Diff line change 1
1
import pytest
2
2
import sys
3
- from pytestqt .exceptions import format_captured_exceptions
3
+ from pytestqt .exceptions import format_captured_exceptions , capture_exceptions
4
4
5
5
6
6
@pytest .mark .parametrize ('raise_error' , [False , True ])
@@ -244,3 +244,35 @@ def event(self, ev):
244
244
qapp .processEvents ()
245
245
246
246
assert [str (e ) for (t , e , tb ) in exceptions ] == ['mistakes were made' ]
247
+
248
+
249
+ def test_exceptions_to_stderr (qapp ):
250
+ """
251
+ Exceptions should still be reported to stderr.
252
+ """
253
+ try :
254
+ from io import StringIO
255
+ except :
256
+ from StringIO import StringIO
257
+ old = sys .stderr
258
+ new = sys .stderr = StringIO ()
259
+
260
+ try :
261
+ called = []
262
+ from pytestqt .qt_compat import QWidget , QEvent
263
+
264
+ class MyWidget (QWidget ):
265
+
266
+ def event (self , ev ):
267
+ called .append (1 )
268
+ raise RuntimeError ('event processed' )
269
+
270
+ w = MyWidget ()
271
+ with capture_exceptions () as exceptions :
272
+ qapp .postEvent (w , QEvent (QEvent .User ))
273
+ qapp .processEvents ()
274
+ assert called
275
+ del exceptions [:]
276
+ assert "raise RuntimeError('event processed')" in new .getvalue ()
277
+ finally :
278
+ sys .stderr = old
You can’t perform that action at this time.
0 commit comments