1616
1717from six import text_type
1818
19+ import pytest
1920
20- tmpl = """
21- <!DOCTYPE html>
22- <head>
23- <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
24- </head>
25- <body>
26- </body>
27- <script>
28- </script>
29- """ # noqa
21+
22+ @pytest .fixture
23+ def tmpl ():
24+ yield ("""
25+ <!DOCTYPE html>
26+ <head>
27+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
28+ </head>
29+ <body>
30+ </body>
31+ <script>
32+ </script>
33+ """ ) # noqa
3034
3135
3236# Root path variable
@@ -51,11 +55,12 @@ def test_figure_rendering():
5155 assert bounds == [[None , None ], [None , None ]], bounds
5256
5357
54- def test_figure_html ():
58+ def test_figure_html (tmpl ):
5559 f = folium .Figure ()
5660 out = f .render ()
5761 out = os .linesep .join ([s .strip () for s in out .splitlines () if s .strip ()])
58- assert out .strip () == tmpl .strip (), '\n ' + out .strip () + '\n ' + '-' * 80 + '\n ' + tmpl .strip () # noqa
62+ tmpl = os .linesep .join ([s .strip () for s in tmpl .splitlines () if s .strip ()])
63+ assert out == tmpl , '\n ' + out + '\n ' + '-' * 80 + '\n ' + tmpl
5964
6065 bounds = f .get_bounds ()
6166 assert bounds == [[None , None ], [None , None ]], bounds
@@ -164,43 +169,49 @@ def test_get_vegalite_major_version():
164169
165170 assert vegalite_v1 ._get_vegalite_major_versions (spec_v1 ) == '1'
166171
167- spec_no_version = {'config' : {'view' : {'height' : 300 , 'width' : 400 }},
168- 'data' : {'name' : 'data-aac17e868e23f98b5e0830d45504be45' },
169- 'datasets' : {'data-aac17e868e23f98b5e0830d45504be45' : [{'folium usage' : 0 ,
170- 'happiness' : 1.0 },
171- {'folium usage' : 1 ,
172- 'happiness' : 2.718281828459045 },
173- {'folium usage' : 2 ,
174- 'happiness' : 7.38905609893065 },
175- {'folium usage' : 3 ,
176- 'happiness' : 20.085536923187668 },
177- {'folium usage' : 4 ,
178- 'happiness' : 54.598150033144236 },
179- {'folium usage' : 5 ,
180- 'happiness' : 148.4131591025766 },
181- {'folium usage' : 6 ,
182- 'happiness' : 403.4287934927351 },
183- {'folium usage' : 7 ,
184- 'happiness' : 1096.6331584284585 },
185- {'folium usage' : 8 ,
186- 'happiness' : 2980.9579870417283 },
187- {'folium usage' : 9 ,
188- 'happiness' : 8103.083927575384 }]},
189- 'encoding' : {'x' : {'field' : 'folium usage' , 'type' : 'quantitative' },
190- 'y' : {'field' : 'happiness' , 'type' : 'quantitative' }},
191- 'mark' : 'point' }
172+ spec_no_version = {
173+ 'config' : {
174+ 'view' : {'height' : 300 , 'width' : 400 }},
175+ 'data' : {'name' : 'data-aac17e868e23f98b5e0830d45504be45' },
176+ 'datasets' : {
177+ 'data-aac17e868e23f98b5e0830d45504be45' : [
178+ {'folium usage' : 0 ,
179+ 'happiness' : 1.0 },
180+ {'folium usage' : 1 ,
181+ 'happiness' : 2.718281828459045 },
182+ {'folium usage' : 2 ,
183+ 'happiness' : 7.38905609893065 },
184+ {'folium usage' : 3 ,
185+ 'happiness' : 20.085536923187668 },
186+ {'folium usage' : 4 ,
187+ 'happiness' : 54.598150033144236 },
188+ {'folium usage' : 5 ,
189+ 'happiness' : 148.4131591025766 },
190+ {'folium usage' : 6 ,
191+ 'happiness' : 403.4287934927351 },
192+ {'folium usage' : 7 ,
193+ 'happiness' : 1096.6331584284585 },
194+ {'folium usage' : 8 ,
195+ 'happiness' : 2980.9579870417283 },
196+ {'folium usage' : 9 ,
197+ 'happiness' : 8103.083927575384 }]},
198+ 'encoding' : {'x' : {'field' : 'folium usage' , 'type' : 'quantitative' },
199+ 'y' : {'field' : 'happiness' , 'type' : 'quantitative' }},
200+ 'mark' : 'point'
201+ }
192202
193203 vegalite_no_version = folium .features .VegaLite (spec_no_version )
194204
195205 assert vegalite_no_version ._get_vegalite_major_versions (spec_no_version ) is None
196206
207+
197208# GeoJsonTooltip GeometryCollection
198209def test_geojson_tooltip ():
199210 m = folium .Map ([30.5 , - 97.5 ], zoom_start = 10 )
200- folium .GeoJson (os .path .join (rootpath , " kuntarajat.geojson" ),
211+ folium .GeoJson (os .path .join (rootpath , ' kuntarajat.geojson' ),
201212 tooltip = folium .GeoJsonTooltip (fields = ['code' , 'name' ])
202213 ).add_to (m )
203214 with warnings .catch_warnings (record = True ) as w :
204215 warnings .simplefilter ('always' )
205216 m ._repr_html_ ()
206- assert issubclass (w [- 1 ].category , UserWarning ), " GeoJsonTooltip GeometryCollection test failed."
217+ assert issubclass (w [- 1 ].category , UserWarning ), ' GeoJsonTooltip GeometryCollection test failed.'
0 commit comments