Skip to content

Commit

Permalink
Fix Selenium heatmap test by using fixed figure size (#2010)
Browse files Browse the repository at this point in the history
* use a fixed figure size and crop the screenshot

* Update test_heat_map_selenium_screenshot.png
  • Loading branch information
Conengmo authored Oct 19, 2024
1 parent 058f958 commit d9e1e9a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/selenium/test_heat_map_selenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ def test_heat_map_with_weights(driver):
This test will fail in non-headless mode because window size will be different.
"""
m = folium.Map((0.5, 0.5), zoom_start=8, tiles=None)
figure_width, figure_height = 800, 600
m = folium.Map(
(0.5, 0.5),
zoom_start=8,
tiles=None,
width=figure_width,
height=figure_height,
)
HeatMap(
# make four dots with different weights: 1, 1, 1.5 and 2.
data=[
Expand All @@ -40,6 +47,8 @@ def test_heat_map_with_weights(driver):
)
screenshot_bytes = base64.b64decode(canvas_base64)
screenshot = Image.open(io.BytesIO(screenshot_bytes))
# window size is not reliable, so crop to a smaller fixed size
screenshot = screenshot.crop((0, 0, figure_width, figure_height))
path = os.path.dirname(__file__)
with open(os.path.join(path, "test_heat_map_selenium_screenshot.png"), "rb") as f:
screenshot_expected = Image.open(f)
Expand Down
Binary file modified tests/selenium/test_heat_map_selenium_screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d9e1e9a

Please sign in to comment.