|
27 | 27 | import sys
|
28 | 28 |
|
29 | 29 | import pytest
|
30 |
| -from PyQt5.QtCore import qWarning |
31 | 30 |
|
32 | 31 | from qutebrowser.utils import log
|
33 | 32 |
|
@@ -230,33 +229,37 @@ class TestHideQtWarning:
|
230 | 229 |
|
231 | 230 | """Tests for hide_qt_warning/QtWarningFilter."""
|
232 | 231 |
|
233 |
| - def test_unfiltered(self, caplog): |
| 232 | + @pytest.fixture() |
| 233 | + def logger(self): |
| 234 | + return logging.getLogger('qt-tests') |
| 235 | + |
| 236 | + def test_unfiltered(self, logger, caplog): |
234 | 237 | """Test a message which is not filtered."""
|
235 | 238 | with log.hide_qt_warning("World", logger='qt-tests'):
|
236 | 239 | with caplog.atLevel(logging.WARNING, logger='qt-tests'):
|
237 |
| - qWarning("Hello World") |
| 240 | + logger.warning("Hello World") |
238 | 241 | assert len(caplog.records()) == 1
|
239 | 242 | record = caplog.records()[0]
|
240 | 243 | assert record.levelname == 'WARNING'
|
241 | 244 | assert record.message == "Hello World"
|
242 | 245 |
|
243 |
| - def test_filtered_exact(self, caplog): |
| 246 | + def test_filtered_exact(self, logger, caplog): |
244 | 247 | """Test a message which is filtered (exact match)."""
|
245 | 248 | with log.hide_qt_warning("Hello", logger='qt-tests'):
|
246 | 249 | with caplog.atLevel(logging.WARNING, logger='qt-tests'):
|
247 |
| - qWarning("Hello") |
| 250 | + logger.warning("Hello") |
248 | 251 | assert not caplog.records()
|
249 | 252 |
|
250 |
| - def test_filtered_start(self, caplog): |
| 253 | + def test_filtered_start(self, logger, caplog): |
251 | 254 | """Test a message which is filtered (match at line start)."""
|
252 | 255 | with log.hide_qt_warning("Hello", logger='qt-tests'):
|
253 | 256 | with caplog.atLevel(logging.WARNING, logger='qt-tests'):
|
254 |
| - qWarning("Hello World") |
| 257 | + logger.warning("Hello World") |
255 | 258 | assert not caplog.records()
|
256 | 259 |
|
257 |
| - def test_filtered_whitespace(self, caplog): |
| 260 | + def test_filtered_whitespace(self, logger, caplog): |
258 | 261 | """Test a message which is filtered (match with whitespace)."""
|
259 | 262 | with log.hide_qt_warning("Hello", logger='qt-tests'):
|
260 | 263 | with caplog.atLevel(logging.WARNING, logger='qt-tests'):
|
261 |
| - qWarning(" Hello World ") |
| 264 | + logger.warning(" Hello World ") |
262 | 265 | assert not caplog.records()
|
0 commit comments