summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-03-12 19:10:25 +0100
committerFlorian Bruhin <me@the-compiler.org>2021-03-12 19:10:28 +0100
commitf5e5057ad90049f808a8e8ee932a0f77089e06f7 (patch)
tree6a2b77d774b3b2408aa6f20f12a8839b0fd3cad5
parentb91e23457858081ae79a74a953c50a7c9d53e319 (diff)
downloadqutebrowser-f5e5057ad90049f808a8e8ee932a0f77089e06f7.tar.gz
qutebrowser-f5e5057ad90049f808a8e8ee932a0f77089e06f7.zip
tests: Further improve and stabilize screenshots
(cherry picked from commit 903e5e294301d8551c06e6f918b726a20a1d391c)
-rw-r--r--tests/end2end/fixtures/quteprocess.py4
-rw-r--r--tests/end2end/test_invocations.py20
2 files changed, 12 insertions, 12 deletions
diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py
index 9ef338768..47548cc63 100644
--- a/tests/end2end/fixtures/quteprocess.py
+++ b/tests/end2end/fixtures/quteprocess.py
@@ -919,8 +919,8 @@ class QuteProc(testprocess.Process):
# Rendering might not be completed yet...
time.sleep(0.5)
- raise ValueError(
- f"Pixel probing for {probe_color} failed (got {probed_color} on last try)")
+ # Using assert again for pytest introspection
+ assert probed_color == probe_color, "Color probing failed, values on last try:"
def press_keys(self, keys):
"""Press the given keys using :fake-key."""
diff --git a/tests/end2end/test_invocations.py b/tests/end2end/test_invocations.py
index 6875db452..82473e50d 100644
--- a/tests/end2end/test_invocations.py
+++ b/tests/end2end/test_invocations.py
@@ -666,12 +666,10 @@ def test_dark_mode(webengine_versions, quteproc_new, request,
# Position chosen by fair dice roll.
# https://xkcd.com/221/
- pos = QPoint(4, 4)
- img = quteproc_new.get_screenshot(probe_pos=pos, probe_color=expected)
-
- color = testutils.Color(img.pixelColor(pos))
- # For pytest debug output
- assert color == expected
+ quteproc_new.get_screenshot(
+ probe_pos=QPoint(4, 4),
+ probe_color=expected,
+ )
def test_dark_mode_mathml(quteproc_new, request, qtbot):
@@ -689,14 +687,16 @@ def test_dark_mode_mathml(quteproc_new, request, qtbot):
quteproc_new.wait_for_js('Image loaded')
# First make sure loading finished by looking outside of the image
- img = quteproc_new.get_screenshot(
+ quteproc_new.get_screenshot(
probe_pos=QPoint(105, 0),
probe_color=testutils.Color(0, 0, 204),
)
- # Then get the actual formula color
- color = testutils.Color(img.pixelColor(QPoint(4, 4)))
- assert color == testutils.Color(255, 255, 255)
+ # Then get the actual formula color, probing again in case it's not displayed yet...
+ quteproc_new.get_screenshot(
+ probe_pos=QPoint(4, 4),
+ probe_color=testutils.Color(255, 255, 255),
+ )
def test_unavailable_backend(request, quteproc_new):