Skip to content

Commit d9e1e9a

Browse files
authored
Fix Selenium heatmap test by using fixed figure size (#2010)
* use a fixed figure size and crop the screenshot * Update test_heat_map_selenium_screenshot.png
1 parent 058f958 commit d9e1e9a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

tests/selenium/test_heat_map_selenium.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@ def test_heat_map_with_weights(driver):
1515
This test will fail in non-headless mode because window size will be different.
1616
1717
"""
18-
m = folium.Map((0.5, 0.5), zoom_start=8, tiles=None)
18+
figure_width, figure_height = 800, 600
19+
m = folium.Map(
20+
(0.5, 0.5),
21+
zoom_start=8,
22+
tiles=None,
23+
width=figure_width,
24+
height=figure_height,
25+
)
1926
HeatMap(
2027
# make four dots with different weights: 1, 1, 1.5 and 2.
2128
data=[
@@ -40,6 +47,8 @@ def test_heat_map_with_weights(driver):
4047
)
4148
screenshot_bytes = base64.b64decode(canvas_base64)
4249
screenshot = Image.open(io.BytesIO(screenshot_bytes))
50+
# window size is not reliable, so crop to a smaller fixed size
51+
screenshot = screenshot.crop((0, 0, figure_width, figure_height))
4352
path = os.path.dirname(__file__)
4453
with open(os.path.join(path, "test_heat_map_selenium_screenshot.png"), "rb") as f:
4554
screenshot_expected = Image.open(f)
Loading

0 commit comments

Comments
 (0)