Skip to content

Commit dcefde3

Browse files
committed
Add test for several location arg data types.
1 parent d0d5b6a commit dcefde3

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

tests/test_folium.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import jinja2
2020
from jinja2 import Environment, PackageLoader
2121

22+
import numpy as np
2223
import pandas as pd
2324

2425
import pytest
@@ -62,6 +63,17 @@ def test_get_templates():
6263
assert isinstance(env, jinja2.environment.Environment)
6364

6465

66+
def test_location_args():
67+
"""Test some data types for a location arg."""
68+
location = np.array([45.5236, -122.6750])
69+
m = folium.Map(location)
70+
assert m.location == [45.5236, -122.6750]
71+
72+
df = pd.DataFrame({"location": [45.5236, -122.6750]})
73+
m = folium.Map(df["location"])
74+
assert m.location == [45.5236, -122.6750]
75+
76+
6577
class TestFolium(object):
6678
"""Test class for the Folium library."""
6779

@@ -108,9 +120,9 @@ def test_init(self):
108120
'name': 'TileLayer',
109121
'id': '00000000000000000000000000000000',
110122
'children': {}
111-
}
112123
}
113124
}
125+
}
114126

115127
def test_cloudmade(self):
116128
"""Test cloudmade tiles and the API key."""
@@ -197,7 +209,8 @@ def test_map_build(self):
197209

198210
# Standard map.
199211
self.setup()
200-
rendered = [line.strip() for line in self.m._parent.render().splitlines() if line.strip()]
212+
rendered = [line.strip()
213+
for line in self.m._parent.render().splitlines() if line.strip()]
201214

202215
html_templ = self.env.get_template('fol_template.html')
203216
attr = 'http://openstreetmap.org'
@@ -332,7 +345,7 @@ def test_fit_bounds(self):
332345
'padding': (3, 3), },
333346
sort_keys=True),
334347
'this': fitbounds,
335-
})
348+
})
336349

337350
assert ''.join(fit_bounds_rendered.split()) in ''.join(out.split())
338351

0 commit comments

Comments
 (0)