From 3a948be49076a743ca08de39ecada5cddc85fd1e Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 21 Oct 2015 22:05:41 +0200 Subject: [PATCH] Add test for unexpected error logging. --- tests/integration/quteprocess.py | 3 +++ tests/integration/test_quteprocess.py | 34 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 tests/integration/test_quteprocess.py diff --git a/tests/integration/quteprocess.py b/tests/integration/quteprocess.py index f69b0073d..d198423cc 100644 --- a/tests/integration/quteprocess.py +++ b/tests/integration/quteprocess.py @@ -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 diff --git a/tests/integration/test_quteprocess.py b/tests/integration/test_quteprocess.py new file mode 100644 index 000000000..373afe1e3 --- /dev/null +++ b/tests/integration/test_quteprocess.py @@ -0,0 +1,34 @@ +# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: + +# Copyright 2015 Florian Bruhin (The Compiler) +# +# 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 . + +"""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()