Skip to content

Commit 6150452

Browse files
committed
use rbga; allow 2 browsers; bump to 1.2.3
1 parent 6e5a644 commit 6150452

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "htmlcmp"
3-
version = "1.2.2"
3+
version = "1.2.3"
44
description = "Compare HTML files by rendered output"
55
classifiers = []
66
authors = [

src/htmlcmp/html_render_diff.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

4-
import shutil
54
import sys
65
import argparse
76
import io
8-
import time
97
from pathlib import Path
108

119
from PIL import Image, ImageChops
@@ -74,18 +72,25 @@ def get_browser(
7472

7573

7674
def html_render_diff(
77-
a: str | Path, b: str | Path, browser: webdriver.Remote
75+
a: str | Path,
76+
b: str | Path,
77+
browser: webdriver.Remote,
78+
browser_b: webdriver.Remote = None,
7879
) -> tuple[Image.Image, tuple[Image.Image, Image.Image]]:
7980
if not isinstance(a, (str, Path)) or not isinstance(b, (str, Path)):
8081
raise TypeError("Both a and b must be str or Path instances")
8182
if not isinstance(browser, webdriver.Remote):
8283
raise TypeError(f"Expected webdriver.Remote, got {type(browser)}")
84+
if browser_b is None:
85+
browser_b = browser
86+
elif not isinstance(browser_b, webdriver.Remote):
87+
raise TypeError(f"Expected webdriver.Remote, got {type(browser_b)}")
8388

8489
image_a = screenshot(browser, to_url(a))
85-
image_b = screenshot(browser, to_url(b))
90+
image_b = screenshot(browser_b, to_url(b))
8691

87-
image_a = image_a.convert("RGB")
88-
image_b = image_b.convert("RGB")
92+
image_a = image_a.convert("RGBA")
93+
image_b = image_b.convert("RGBA")
8994
diff = ImageChops.difference(image_a, image_b)
9095
return diff, (image_a, image_b)
9196

0 commit comments

Comments
 (0)