File tree 2 files changed +34
-2
lines changed 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,11 @@ def pytest_runtest_setup(self, item):
24
24
return
25
25
m = item .get_marker ('qt_log_ignore' )
26
26
if m :
27
- ignore_regexes = m .args
27
+ if m .kwargs .get ('extend' , False ):
28
+ config_regexes = self .config .getini ('qt_log_ignore' )
29
+ ignore_regexes = config_regexes + list (m .args )
30
+ else :
31
+ ignore_regexes = m .args
28
32
else :
29
33
ignore_regexes = self .config .getini ('qt_log_ignore' )
30
34
item .qt_log_capture = _QtMessageCapture (ignore_regexes )
@@ -277,4 +281,4 @@ def toterminal(self, out):
277
281
self .fileloc .toterminal (out )
278
282
for name , content , sep in self .sections :
279
283
out .sep (sep , name )
280
- out .line (content )
284
+ out .line (content )
Original file line number Diff line number Diff line change @@ -340,6 +340,34 @@ def test1():
340
340
res .assertoutcome (passed = passed , failed = int (not passed ))
341
341
342
342
343
+ @pytest .mark .parametrize ('message' , ['match-global' , 'match-mark' ])
344
+ def test_logging_mark_with_extend (testdir , message ):
345
+ """
346
+ Test qt_log_ignore mark with extend=True.
347
+
348
+ :type testdir: _pytest.pytester.TmpTestdir
349
+ """
350
+ testdir .makeini (
351
+ """
352
+ [pytest]
353
+ qt_log_level_fail = CRITICAL
354
+ qt_log_ignore = match-global
355
+ """
356
+ )
357
+ testdir .makepyfile (
358
+ """
359
+ from pytestqt.qt_compat import qWarning, qCritical
360
+ import pytest
361
+
362
+ @pytest.mark.qt_log_ignore('match-mark', extend=True)
363
+ def test1():
364
+ qCritical('{message}')
365
+ """ .format (message = message )
366
+ )
367
+ res = testdir .inline_run ()
368
+ res .assertoutcome (passed = 1 , failed = 0 )
369
+
370
+
343
371
@pytest .mark .parametrize ('apply_mark' , [True , False ])
344
372
def test_logging_fails_ignore_mark_multiple (testdir , apply_mark ):
345
373
"""
You can’t perform that action at this time.
0 commit comments