Skip to content

Commit

Permalink
fix: GUI test: make sure images are in the same color mode
Browse files Browse the repository at this point in the history
  • Loading branch information
markus-stoll committed May 29, 2024
1 parent 50a91c6 commit 96bec12
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/ui/test_startpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import pytest
from diffimg import diff
from PIL import Image
from selenium.webdriver.remote.webdriver import WebDriver

from .helpers import (
Expand Down Expand Up @@ -33,6 +34,13 @@ def take_and_diff_snapshot(
reference_screenshot_path = old_screenshots_folder / f"{name}-{browser_name}.png"

if reference_screenshot_path.is_file():
# make sure both are in the same color mode
im1 = Image.open(str(reference_screenshot_path))
im2 = Image.open(str(diff_path))
if im1.mode != im2.mode:
im1 = im1.convert("RGB")
im2 = im2.convert("RGB")

diff_ratio = diff(
str(reference_screenshot_path),
str(new_screenshot_path),
Expand Down

0 comments on commit 96bec12

Please sign in to comment.