Skip to content

Commit 1e9d4fe

Browse files
authored
Fix Pytest warnings (#1699)
1 parent 36ba29a commit 1e9d4fe

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

tests/test_folium.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def test_location_args():
6464
class TestFolium:
6565
"""Test class for the Folium library."""
6666

67-
def setup(self):
67+
def setup_method(self):
6868
"""Setup Folium Map."""
6969
attr = "http://openstreetmap.org"
7070
self.m = folium.Map(
@@ -191,8 +191,6 @@ def test_choropleth_features(self):
191191
It also tests that all parameters work as expected regarding
192192
nan and missing values.
193193
"""
194-
self.setup()
195-
196194
with open(os.path.join(rootpath, "us-counties.json")) as f:
197195
geo_data = json.load(f)
198196
data = {"1001": -1}
@@ -263,8 +261,6 @@ def test_choropleth_geopandas_numeric(self):
263261
key_on field is dtype = str, while column 0 is dtype = int
264262
All geometries have matching values (no nan_fill_color allowed)
265263
"""
266-
self.setup()
267-
268264
with open(os.path.join(rootpath, "geo_grid.json")) as f:
269265
geo_data = json.load(f)
270266

@@ -296,8 +292,6 @@ def test_choropleth_geopandas_mixed(self):
296292
key_on field is dtype = str, while column 0 is dtype = object (mixed int and str)
297293
All geometries have matching values (no nan_fill_color allowed)
298294
"""
299-
self.setup()
300-
301295
with open(os.path.join(rootpath, "geo_grid.json")) as f:
302296
geo_data = json.load(f)
303297

@@ -344,8 +338,6 @@ def test_choropleth_geopandas_str(self):
344338
key_on field and column 0 from data are both strings.
345339
All geometries have matching values (no nan_fill_color allowed)
346340
"""
347-
self.setup()
348-
349341
with open(os.path.join(rootpath, "geo_grid.json")) as f:
350342
geo_data = json.load(f)
351343

@@ -393,8 +385,6 @@ def test_tile_attr_unicode(self):
393385
def test_fit_bounds(self):
394386
"""Test fit_bounds."""
395387
bounds = ((52.193636, -2.221575), (52.636878, -1.139759))
396-
397-
self.setup()
398388
self.m.fit_bounds(bounds)
399389
fitbounds = [
400390
val
@@ -414,7 +404,8 @@ def test_fit_bounds(self):
414404

415405
assert "".join(fit_bounds_rendered.split()) in "".join(out.split())
416406

417-
self.setup()
407+
def test_fit_bounds_2(self):
408+
bounds = ((52.193636, -2.221575), (52.636878, -1.139759))
418409
self.m.fit_bounds(bounds, max_zoom=15, padding=(3, 3))
419410
fitbounds = [
420411
val
@@ -445,8 +436,6 @@ def test_fit_bounds(self):
445436

446437
def test_custom_icon(self):
447438
"""Test CustomIcon."""
448-
self.setup()
449-
450439
icon_image = "http://leafletjs.com/docs/images/leaf-green.png"
451440
shadow_image = "http://leafletjs.com/docs/images/leaf-shadow.png"
452441

@@ -496,7 +485,6 @@ def test_global_switches(self):
496485
assert m.global_switches.no_touch
497486
assert m.global_switches.disable_3d
498487

499-
@pytest.mark.web
500488
def test_json_request(self):
501489
"""Test requests for remote GeoJSON files."""
502490
self.m = folium.Map(zoom_start=4)

tests/test_map.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
----------------
44
55
"""
6+
import warnings
7+
68
import numpy as np
79
import pytest
810

@@ -128,10 +130,10 @@ def test_popup_backticks_already_escaped():
128130

129131
def test_icon_valid_marker_colors():
130132
assert len(Icon.color_options) == 19
131-
with pytest.warns(None) as record:
133+
with warnings.catch_warnings():
134+
warnings.simplefilter("error")
132135
for color in Icon.color_options:
133136
Icon(color=color)
134-
assert len(record) == 0
135137

136138

137139
def test_custom_pane_show():

0 commit comments

Comments
 (0)