Skip to content

Commit

Permalink
fix tests for latest pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
ocefpaf committed Nov 16, 2018
1 parent ad997a2 commit f7840ee
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions tests/test_repr.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,21 @@


@pytest.fixture
def make_map(png_enabled=False):
m = folium.Map(png_enabled=png_enabled)
return m
def m():
yield folium.Map(png_enabled=False)


def test__repr_html_is_str():
html = make_map()._repr_html_()
@pytest.fixture
def m_png():
yield folium.Map(png_enabled=True)

def test__repr_html_is_str(m):
html = m._repr_html_()
assert isinstance(html, str)


def test_valid_html():
html = make_map()._repr_html_()
def test_valid_html(m):
html = m._repr_html_()
parts = html.split('><')
assert len(parts) == 6
assert parts[0].lstrip('<div ') == 'style="width:100%;"'
Expand All @@ -41,19 +44,19 @@ def test_valid_html():
assert parts[5] == '/div>'


def test__repr_png_no_image():
png = make_map(png_enabled=False)._repr_png_()
def test__repr_png_no_image(m):
png = m._repr_png_()
assert png is None


def test__repr_png_is_bytes():
png = make_map(png_enabled=True)._repr_png_()
def test__repr_png_is_bytes(m_png):
png = m_png._repr_png_()
assert isinstance(png, bytes)


@pytest.mark.skipif(sys.version_info < (3, 0),
reason="Doesn't work on Python 2.7.")
def test_valid_png():
png = make_map(png_enabled=True)._repr_png_()
def test_valid_png(m_png):
png = m_png._repr_png_()
img = PIL.Image.open(io.BytesIO(png))
isinstance(img, PIL.PngImagePlugin.PngImageFile)

0 comments on commit f7840ee

Please sign in to comment.