From 2f9a857a27130f7e12ff17f9695e004c42c8ca4e Mon Sep 17 00:00:00 2001 From: Jay Kamat Date: Wed, 8 Nov 2017 23:46:12 -0500 Subject: [PATCH] Add test for styling error pages --- tests/unit/javascript/conftest.py | 9 +++++---- tests/unit/javascript/stylesheet/test_stylesheet.py | 6 ++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/unit/javascript/conftest.py b/tests/unit/javascript/conftest.py index 25fc9ea9d..fa8c48f27 100644 --- a/tests/unit/javascript/conftest.py +++ b/tests/unit/javascript/conftest.py @@ -195,16 +195,17 @@ class JSWebEngineTester: self.webview.setHtml(template.render(**kwargs)) assert blocker.args == [True] - def load_file(self, path: str): + def load_file(self, path: str, force=False): """Loads a file from disk""" self.load_url(QUrl.fromLocalFile( - os.path.join(os.path.dirname(__file__), path))) + os.path.join(os.path.dirname(__file__), path)), force) - def load_url(self, url: QUrl): + def load_url(self, url: QUrl, force=False): """Load a given QUrl.""" with self._qtbot.waitSignal(self.webview.loadFinished) as blocker: self.webview.load(url) - assert blocker.args == [True] + if not force: + assert blocker.args == [True] import time time.sleep(1) diff --git a/tests/unit/javascript/stylesheet/test_stylesheet.py b/tests/unit/javascript/stylesheet/test_stylesheet.py index bae5f3e4d..736111619 100644 --- a/tests/unit/javascript/stylesheet/test_stylesheet.py +++ b/tests/unit/javascript/stylesheet/test_stylesheet.py @@ -111,3 +111,9 @@ def test_no_set_svg(stylesheet_tester): stylesheet_tester.check_set(None) stylesheet_tester.set_css("body {background-color: rgb(0, 255, 0);}") stylesheet_tester.check_set(None) + +def test_set_error(stylesheet_tester): + """Test stylesheet modifies file not found error pages.""" + stylesheet_tester.init_stylesheet() + stylesheet_tester.js.load_file('non-existent.html', force=True) + stylesheet_tester.check_set(GREEN_BODY_BG)