Add test for unexpected error logging.
This commit is contained in:
parent
ac148c11ec
commit
3a948be490
@ -60,6 +60,7 @@ class QuteProc(testprocess.Process):
|
||||
executing_command = pyqtSignal()
|
||||
setting_done = pyqtSignal()
|
||||
url_loaded = pyqtSignal()
|
||||
got_error = pyqtSignal()
|
||||
|
||||
def __init__(self, httpbin, parent=None):
|
||||
super().__init__(parent)
|
||||
@ -106,6 +107,8 @@ class QuteProc(testprocess.Process):
|
||||
elif (log_line.category == 'webview' and
|
||||
url_loaded_pattern.match(log_line.message)):
|
||||
self.url_loaded.emit()
|
||||
elif log_line.loglevel in ['WARNING', 'ERROR']:
|
||||
self.got_error.emit()
|
||||
|
||||
return log_line
|
||||
|
||||
|
34
tests/integration/test_quteprocess.py
Normal file
34
tests/integration/test_quteprocess.py
Normal file
@ -0,0 +1,34 @@
|
||||
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
||||
|
||||
# Copyright 2015 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
#
|
||||
# This file is part of qutebrowser.
|
||||
#
|
||||
# qutebrowser is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# qutebrowser is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""Test the quteproc fixture used for tests."""
|
||||
|
||||
import pytest
|
||||
|
||||
import testprocess # pylint: disable=import-error
|
||||
|
||||
|
||||
def test_quteproc_error_message(qtbot, quteproc):
|
||||
"""Make sure the test fails with an unexpected error message."""
|
||||
with qtbot.waitSignal(quteproc.got_error, raising=True):
|
||||
quteproc.send_cmd(':message-error test')
|
||||
# Usually we wouldn't call this from inside a test, but here we force the
|
||||
# error to occur during the test rather than at teardown time.
|
||||
with pytest.raises(pytest.fail.Exception):
|
||||
quteproc.after_test()
|
Loading…
Reference in New Issue
Block a user