Skip to content

Commit 70986ce

Browse files
committed
PNG repr tests
1 parent e4ea523 commit 70986ce

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

tests/test_repr.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# -*- coding: utf-8 -*-
2+
""""
3+
Folium _repr_*_ Tests
4+
---------------------
5+
6+
"""
7+
8+
import io
9+
10+
import folium
11+
12+
import pytest
13+
14+
import PIL.Image
15+
16+
17+
@pytest.fixture
18+
def make_map():
19+
m = folium.Map()
20+
return m
21+
22+
23+
def test__repr_html_is_str():
24+
html = make_map()._repr_html_()
25+
assert isinstance(html, str)
26+
27+
28+
def test_valid_html():
29+
html = make_map()._repr_html_()
30+
parts = html.split('><')
31+
assert len(parts) == 6
32+
assert parts[0].lstrip('<div ') == 'style="width:100%;"'
33+
assert parts[1].lstrip('<div ') == 'style="position:relative;width:100%;height:0;padding-bottom:60%;"' # noqa
34+
assert parts[2].startswith('iframe')
35+
assert parts[3] == '/iframe'
36+
assert parts[4] == '/div'
37+
assert parts[5] == '/div>'
38+
39+
40+
def test__repr_png_is_bytes():
41+
png = make_map()._repr_png_()
42+
assert isinstance(png, bytes)
43+
44+
45+
def test_valid_png():
46+
png = make_map()._repr_png_()
47+
img = PIL.Image.open(io.BytesIO(png))
48+
isinstance(img, PIL.PngImagePlugin.PngImageFile)

0 commit comments

Comments
 (0)