From b588f54a5315fadf0ee8192e1604f88adb489c73 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 19 Mar 2018 20:43:55 +0100 Subject: [PATCH] Fail javascript tests on logging messages --- tests/unit/javascript/conftest.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/tests/unit/javascript/conftest.py b/tests/unit/javascript/conftest.py index f55ca75b5..a71baef11 100644 --- a/tests/unit/javascript/conftest.py +++ b/tests/unit/javascript/conftest.py @@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . -"""pylint conftest file for javascript test.""" +"""pytest conftest file for javascript tests.""" import os import os.path @@ -41,11 +41,18 @@ class JSTester: _jinja_env: The jinja2 environment used to get templates. """ - def __init__(self, tab, qtbot): + def __init__(self, tab, qtbot, config_stub): self.tab = tab self.qtbot = qtbot loader = jinja2.FileSystemLoader(os.path.dirname(__file__)) self._jinja_env = jinja2.Environment(loader=loader, autoescape=True) + # Make sure logging via JS fails tests + config_stub.val.content.javascript.log = { + 'error': 'error', + 'info': 'error', + 'unknown': 'error', + 'warning': 'error' + } def load(self, path, **kwargs): """Load and display the given jinja test data. @@ -109,18 +116,18 @@ class JSTester: @pytest.fixture -def js_tester_webkit(webkit_tab, qtbot): +def js_tester_webkit(webkit_tab, qtbot, config_stub): """Fixture to test javascript snippets in webkit.""" - return JSTester(webkit_tab, qtbot) + return JSTester(webkit_tab, qtbot, config_stub) @pytest.fixture -def js_tester_webengine(webengine_tab, qtbot): +def js_tester_webengine(webengine_tab, qtbot, config_stub): """Fixture to test javascript snippets in webengine.""" - return JSTester(webengine_tab, qtbot) + return JSTester(webengine_tab, qtbot, config_stub) @pytest.fixture -def js_tester(web_tab, qtbot): +def js_tester(web_tab, qtbot, config_stub): """Fixture to test javascript snippets with both backends.""" - return JSTester(web_tab, qtbot) + return JSTester(web_tab, qtbot, config_stub)