File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -325,3 +325,32 @@ def foo():
325
325
])
326
326
else :
327
327
res .stdout .fnmatch_lines ('*test_lineno_failure.py:2: Failure*' )
328
+
329
+
330
+ @pytest .mark .skipif (QT_API != 'pyqt5' ,
331
+ reason = 'Context information only available in PyQt5' )
332
+ def test_context_none (testdir ):
333
+ """
334
+ Sometimes PyQt5 will emit a context with some/all attributes set as None
335
+ instead of appropriate file, function and line number.
336
+
337
+ Test that when this happens the plugin doesn't break.
338
+
339
+ :type testdir: _pytest.pytester.TmpTestdir
340
+ """
341
+ testdir .makepyfile (
342
+ """
343
+ from pytestqt.qt_compat import QtWarningMsg
344
+
345
+ def test_foo(request):
346
+ log_capture = request.node.qt_log_capture
347
+ context = log_capture._Context(None, None, None)
348
+ log_capture._handle(QtWarningMsg, "WARNING message", context)
349
+ assert 0
350
+ """
351
+ )
352
+ res = testdir .runpytest ()
353
+ res .stdout .fnmatch_lines ([
354
+ '*Failure*' ,
355
+ '*None:None:None:*' ,
356
+ ])
You can’t perform that action at this time.
0 commit comments