htmlcmp 2.4.2__tar.gz → 2.4.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/PKG-INFO +3 -1
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/README.md +2 -0
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/pyproject.toml +1 -1
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/src/htmlcmp/comparison_worker.py +3 -3
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/src/htmlcmp/html_render_diff.py +9 -1
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/src/htmlcmp.egg-info/PKG-INFO +3 -1
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/tests/test_browser_transport.py +42 -0
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/tests/test_comparison_worker.py +17 -3
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/setup.cfg +0 -0
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/src/htmlcmp/__init__.py +0 -0
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/src/htmlcmp/common.py +0 -0
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/src/htmlcmp/compare_output_cli.py +0 -0
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/src/htmlcmp/compare_output_server.py +0 -0
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/src/htmlcmp/static/common.js +0 -0
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/src/htmlcmp/static/compare.js +0 -0
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/src/htmlcmp/static/index.js +0 -0
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/src/htmlcmp/static/style.css +0 -0
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/src/htmlcmp/templates/compare.html +0 -0
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/src/htmlcmp/templates/index.html +0 -0
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/src/htmlcmp/templates/missing.html +0 -0
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/src/htmlcmp/tidy_output.py +0 -0
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/src/htmlcmp.egg-info/SOURCES.txt +0 -0
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/src/htmlcmp.egg-info/dependency_links.txt +0 -0
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/src/htmlcmp.egg-info/entry_points.txt +0 -0
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/src/htmlcmp.egg-info/requires.txt +0 -0
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/src/htmlcmp.egg-info/top_level.txt +0 -0
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/tests/test_collect_tasks.py +0 -0
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/tests/test_compare_html_retries.py +0 -0
- {htmlcmp-2.4.2 → htmlcmp-2.4.3}/tests/test_html_render_diff.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: htmlcmp
|
|
3
|
-
Version: 2.4.
|
|
3
|
+
Version: 2.4.3
|
|
4
4
|
Summary: Compare HTML files by rendered output
|
|
5
5
|
Author: Andreas Stefl
|
|
6
6
|
Maintainer-email: Andreas Stefl <stefl.andreas@gmail.com>
|
|
@@ -36,6 +36,8 @@ Used for regression testing in https://github.com/opendocument-app/OpenDocument.
|
|
|
36
36
|
including browser startup, both screenshots, and any `--retries` of a pixel
|
|
37
37
|
mismatch. The deadline starts when a worker takes the file, not while it waits
|
|
38
38
|
in the queue. Use a larger positive value for especially expensive pages.
|
|
39
|
+
The same value configures WebDriver's HTTP and page-load timeouts, so increasing
|
|
40
|
+
the deadline is not cut short by Selenium's default 120-second HTTP timeout.
|
|
39
41
|
|
|
40
42
|
A timeout is reported as an error and makes the command exit unsuccessfully.
|
|
41
43
|
The worker and its browser processes are discarded; the next file gets a fresh
|
|
@@ -16,6 +16,8 @@ Used for regression testing in https://github.com/opendocument-app/OpenDocument.
|
|
|
16
16
|
including browser startup, both screenshots, and any `--retries` of a pixel
|
|
17
17
|
mismatch. The deadline starts when a worker takes the file, not while it waits
|
|
18
18
|
in the queue. Use a larger positive value for especially expensive pages.
|
|
19
|
+
The same value configures WebDriver's HTTP and page-load timeouts, so increasing
|
|
20
|
+
the deadline is not cut short by Selenium's default 120-second HTTP timeout.
|
|
19
21
|
|
|
20
22
|
A timeout is reported as an error and makes the command exit unsuccessfully.
|
|
21
23
|
The worker and its browser processes are discarded; the next file gets a fresh
|
|
@@ -15,7 +15,7 @@ from htmlcmp.html_render_diff import get_browser
|
|
|
15
15
|
logger = logging.getLogger(__name__)
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
def _compare_loop(connection, driver):
|
|
18
|
+
def _compare_loop(connection, driver, timeout):
|
|
19
19
|
browser = None
|
|
20
20
|
try:
|
|
21
21
|
while True:
|
|
@@ -28,7 +28,7 @@ def _compare_loop(connection, driver):
|
|
|
28
28
|
and a.suffix == ".html"
|
|
29
29
|
and not filecmp.cmp(a, b, shallow=False)
|
|
30
30
|
):
|
|
31
|
-
browser = get_browser(driver)
|
|
31
|
+
browser = get_browser(driver, timeout=timeout)
|
|
32
32
|
result = compare_files(a, b, browser=browser, **kwargs)
|
|
33
33
|
connection.send((True, result))
|
|
34
34
|
except Exception as exc:
|
|
@@ -52,7 +52,7 @@ class ComparisonWorker:
|
|
|
52
52
|
context = multiprocessing.get_context("spawn")
|
|
53
53
|
self._connection, child = context.Pipe()
|
|
54
54
|
self._process = context.Process(
|
|
55
|
-
target=_compare_loop, args=(child, self.driver), daemon=True
|
|
55
|
+
target=_compare_loop, args=(child, self.driver, self.timeout), daemon=True
|
|
56
56
|
)
|
|
57
57
|
try:
|
|
58
58
|
self._process.start()
|
|
@@ -100,7 +100,11 @@ def content_bottom(image: Image.Image) -> int:
|
|
|
100
100
|
|
|
101
101
|
|
|
102
102
|
def get_browser(
|
|
103
|
-
driver: str,
|
|
103
|
+
driver: str,
|
|
104
|
+
max_width: int = 1000,
|
|
105
|
+
max_height: int = 10000,
|
|
106
|
+
*,
|
|
107
|
+
timeout: float | None = None,
|
|
104
108
|
) -> webdriver.Remote:
|
|
105
109
|
if not isinstance(driver, str):
|
|
106
110
|
raise TypeError(f"Expected str, got {type(driver)}")
|
|
@@ -122,6 +126,10 @@ def get_browser(
|
|
|
122
126
|
# Local WebDriver constructors do not expose ClientConfig. Disable urllib3's
|
|
123
127
|
# automatic GET retries on their pool: a stalled screenshot must fail once.
|
|
124
128
|
browser.command_executor._conn.connection_pool_kw["retries"] = 0
|
|
129
|
+
if timeout is not None:
|
|
130
|
+
# The CLI's parent process enforces the whole comparison deadline.
|
|
131
|
+
browser.command_executor._client_config.timeout = timeout
|
|
132
|
+
browser.set_page_load_timeout(timeout)
|
|
125
133
|
browser.set_window_size(max_width, max_height)
|
|
126
134
|
return browser
|
|
127
135
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: htmlcmp
|
|
3
|
-
Version: 2.4.
|
|
3
|
+
Version: 2.4.3
|
|
4
4
|
Summary: Compare HTML files by rendered output
|
|
5
5
|
Author: Andreas Stefl
|
|
6
6
|
Maintainer-email: Andreas Stefl <stefl.andreas@gmail.com>
|
|
@@ -36,6 +36,8 @@ Used for regression testing in https://github.com/opendocument-app/OpenDocument.
|
|
|
36
36
|
including browser startup, both screenshots, and any `--retries` of a pixel
|
|
37
37
|
mismatch. The deadline starts when a worker takes the file, not while it waits
|
|
38
38
|
in the queue. Use a larger positive value for especially expensive pages.
|
|
39
|
+
The same value configures WebDriver's HTTP and page-load timeouts, so increasing
|
|
40
|
+
the deadline is not cut short by Selenium's default 120-second HTTP timeout.
|
|
39
41
|
|
|
40
42
|
A timeout is reported as an error and makes the command exit unsuccessfully.
|
|
41
43
|
The worker and its browser processes are discarded; the next file gets a fresh
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""A stalled screenshot gets one HTTP request, not four timeout periods."""
|
|
2
2
|
|
|
3
3
|
import threading
|
|
4
|
+
import time
|
|
4
5
|
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|
5
6
|
from unittest.mock import Mock
|
|
6
7
|
|
|
@@ -49,3 +50,44 @@ def test_screenshot_transport_does_not_retry(monkeypatch, driver, factory):
|
|
|
49
50
|
server.shutdown()
|
|
50
51
|
server.server_close()
|
|
51
52
|
thread.join()
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@pytest.mark.parametrize(
|
|
56
|
+
"driver,factory", [("firefox", "Firefox"), ("chrome", "Chrome")]
|
|
57
|
+
)
|
|
58
|
+
def test_longer_deadline_allows_a_slow_screenshot(monkeypatch, driver, factory):
|
|
59
|
+
class Handler(BaseHTTPRequestHandler):
|
|
60
|
+
def do_GET(self):
|
|
61
|
+
time.sleep(0.25)
|
|
62
|
+
body = b'{"value":"image"}'
|
|
63
|
+
self.send_response(200)
|
|
64
|
+
self.send_header("Content-Type", "application/json")
|
|
65
|
+
self.send_header("Content-Length", str(len(body)))
|
|
66
|
+
self.end_headers()
|
|
67
|
+
self.wfile.write(body)
|
|
68
|
+
|
|
69
|
+
def log_message(self, *args):
|
|
70
|
+
pass
|
|
71
|
+
|
|
72
|
+
server = ThreadingHTTPServer(("127.0.0.1", 0), Handler)
|
|
73
|
+
thread = threading.Thread(target=server.serve_forever, daemon=True)
|
|
74
|
+
thread.start()
|
|
75
|
+
connection = RemoteConnection(
|
|
76
|
+
client_config=ClientConfig(
|
|
77
|
+
remote_server_addr=f"http://127.0.0.1:{server.server_port}",
|
|
78
|
+
timeout=0.1,
|
|
79
|
+
)
|
|
80
|
+
)
|
|
81
|
+
browser = Mock(command_executor=connection)
|
|
82
|
+
monkeypatch.setattr(render.webdriver, factory, Mock(return_value=browser))
|
|
83
|
+
try:
|
|
84
|
+
render.get_browser(driver, timeout=2)
|
|
85
|
+
browser.set_page_load_timeout.assert_called_once_with(2)
|
|
86
|
+
assert connection.execute(Command.SCREENSHOT, {"sessionId": "test"}) == {
|
|
87
|
+
"value": "image"
|
|
88
|
+
}
|
|
89
|
+
finally:
|
|
90
|
+
connection.close()
|
|
91
|
+
server.shutdown()
|
|
92
|
+
server.server_close()
|
|
93
|
+
thread.join()
|
|
@@ -14,7 +14,7 @@ from htmlcmp import comparison_worker as worker_module
|
|
|
14
14
|
from htmlcmp.comparison_worker import ComparisonExecutor, ComparisonWorker
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
def controlled_worker(connection, driver):
|
|
17
|
+
def controlled_worker(connection, driver, timeout):
|
|
18
18
|
while True:
|
|
19
19
|
request = connection.recv()
|
|
20
20
|
if request is None:
|
|
@@ -35,14 +35,14 @@ def controlled_worker(connection, driver):
|
|
|
35
35
|
connection.send((True, os.getpid()))
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
def hanging_shutdown(connection, driver):
|
|
38
|
+
def hanging_shutdown(connection, driver, timeout):
|
|
39
39
|
connection.recv()
|
|
40
40
|
connection.send((True, os.getpid()))
|
|
41
41
|
connection.recv()
|
|
42
42
|
time.sleep(60)
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
def no_startup_response(connection, driver):
|
|
45
|
+
def no_startup_response(connection, driver, timeout):
|
|
46
46
|
time.sleep(60)
|
|
47
47
|
|
|
48
48
|
|
|
@@ -140,6 +140,20 @@ def test_identical_html_does_not_need_a_browser(tmp_path):
|
|
|
140
140
|
assert executor.submit(executor.compare, a, b).result() is True
|
|
141
141
|
|
|
142
142
|
|
|
143
|
+
def test_comparison_deadline_reaches_browser_transport(monkeypatch, tmp_path):
|
|
144
|
+
a, b = tmp_path / "a.html", tmp_path / "b.html"
|
|
145
|
+
a.write_text("one")
|
|
146
|
+
b.write_text("two")
|
|
147
|
+
connection = Mock()
|
|
148
|
+
connection.recv.side_effect = [(a, b, {}), None]
|
|
149
|
+
factory = Mock()
|
|
150
|
+
monkeypatch.setattr(worker_module, "get_browser", factory)
|
|
151
|
+
monkeypatch.setattr(worker_module, "compare_files", Mock(return_value=True))
|
|
152
|
+
worker_module._compare_loop(connection, "firefox", 900)
|
|
153
|
+
factory.assert_called_once_with("firefox", timeout=900)
|
|
154
|
+
connection.send.assert_called_once_with((True, True))
|
|
155
|
+
|
|
156
|
+
|
|
143
157
|
def test_startup_failure_is_reported_per_file(tmp_path):
|
|
144
158
|
a, b = tmp_path / "a.html", tmp_path / "b.html"
|
|
145
159
|
a.write_text("one")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|