MCPcopy Index your code
hub / github.com/python-visualization/folium / test_screenshot

Function test_screenshot

tests/snapshots/test_snapshots.py:20–43  ·  view source on GitHub ↗
(path: str)

Source from the content-addressed store, hash-verified

18
19@pytest.mark.parametrize("path", paths)
20def test_screenshot(path: str):
21 driver = webdriver.Chrome(options=options)
22 m = importlib.import_module(f"tests.snapshots.modules.{path}").m
23 img_data = m._to_png(3, driver=driver, size=(800, 800))
24 img_a = Image.open(io.BytesIO(img_data))
25 img_a.save(f"/tmp/screenshot_new_{path}.png")
26
27 if os.path.exists(f"tests/snapshots/screenshots/screenshot_{path}.png"):
28 img_b = Image.open(f"tests/snapshots/screenshots/screenshot_{path}.png")
29
30 img_diff = Image.new("RGBA", img_a.size)
31 # note how there is no need to specify dimensions
32 mismatch = pixelmatch(img_a, img_b, img_diff, threshold=0.2, includeAA=False)
33
34 img_diff.save(f"/tmp/screenshot_diff_{path}.png")
35 m.save(f"/tmp/folium_map_{path}.html")
36 assert mismatch < 200
37
38 else: # pragma: no cover
39 shutil.copy(
40 f"/tmp/screenshot_new_{path}.png",
41 f"tests/snapshots/screenshots/screenshot_{path}.png",
42 )
43 raise Exception("no screenshot available, generating new")

Callers

nothing calls this directly

Calls 1

_to_pngMethod · 0.80

Tested by

no test coverage detected