1212import pandas as pd
1313import pytest
1414import xyzservices .providers as xyz
15- from jinja2 import Environment , PackageLoader
15+ from jinja2 import Template
1616from jinja2 .utils import htmlsafe_json_dumps
1717
1818import folium
@@ -69,7 +69,21 @@ def setup_method(self):
6969 font_size = "1.5rem" ,
7070 attr = attr ,
7171 )
72- self .env = Environment (loader = PackageLoader ("folium" , "templates" ))
72+ self .fit_bounds_template = Template (
73+ """
74+ {% if autobounds %}
75+ var autobounds = L.featureGroup({{ features }}).getBounds()
76+ {% if not bounds %}
77+ {% set bounds = "autobounds" %}
78+ {% endif %}
79+ {% endif %}
80+ {% if bounds %}
81+ {{this._parent.get_name()}}.fitBounds({{ bounds }},
82+ {{ fit_bounds_options }}
83+ );
84+ {% endif %}
85+ """
86+ )
7387
7488 def test_init (self ):
7589 """Test map initialization."""
@@ -385,8 +399,7 @@ def test_fit_bounds(self):
385399 ][0 ]
386400 out = self .m ._parent .render ()
387401
388- fit_bounds_tpl = self .env .get_template ("fit_bounds.js" )
389- fit_bounds_rendered = fit_bounds_tpl .render (
402+ fit_bounds_rendered = self .fit_bounds_template .render (
390403 {
391404 "bounds" : json .dumps (bounds ),
392405 "this" : fitbounds ,
@@ -406,8 +419,7 @@ def test_fit_bounds_2(self):
406419 ][0 ]
407420 out = self .m ._parent .render ()
408421
409- fit_bounds_tpl = self .env .get_template ("fit_bounds.js" )
410- fit_bounds_rendered = fit_bounds_tpl .render (
422+ fit_bounds_rendered = self .fit_bounds_template .render (
411423 {
412424 "bounds" : json .dumps (bounds ),
413425 "fit_bounds_options" : json .dumps (
0 commit comments