Skip to content

Commit 60f3a89

Browse files
authored
Merge pull request #757 from sanga/small_cleanups
Small cleanups
2 parents 0b23308 + c3958ad commit 60f3a89

File tree

2 files changed

+17
-29
lines changed

2 files changed

+17
-29
lines changed

folium/features.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -373,19 +373,11 @@ def __init__(self, data, style_function=None, name=None,
373373
else:
374374
raise ValueError('Unhandled object {!r}.'.format(data))
375375

376-
if style_function is None:
377-
def style_function(x):
378-
return {}
379-
380-
self.style_function = style_function
376+
self.style_function = style_function or (lambda x: {})
381377

382378
self.highlight = highlight_function is not None
383379

384-
if highlight_function is None:
385-
def highlight_function(x):
386-
return {}
387-
388-
self.highlight_function = highlight_function
380+
self.highlight_function = highlight_function or (lambda x: {})
389381

390382
self.smooth_factor = smooth_factor
391383

tests/test_folium.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,12 @@
3434
rootpath = os.path.abspath(os.path.dirname(__file__))
3535

3636
# For testing remote requests
37-
remote_url = '/'.join([
38-
'https://raw.githubusercontent.com',
39-
'python-visualization/folium/master',
40-
'examples/data/us-states.json'])
37+
remote_url = 'https://raw.githubusercontent.com/python-visualization/folium/master/examples/data/us-states.json' # noqa
4138

4239

4340
def setup_data():
4441
"""Import economic data for testing."""
45-
with open(os.path.join(rootpath, 'us-counties.json'), 'r') as f:
42+
with open(os.path.join(rootpath, 'us-counties.json')) as f:
4643
get_id = json.load(f)
4744

4845
county_codes = [x['id'] for x in get_id['features']]
@@ -162,7 +159,6 @@ def test_custom_tile(self):
162159
bounds = m.get_bounds()
163160
assert bounds == [[None, None], [None, None]], bounds
164161

165-
166162
def test_feature_group(self):
167163
"""Test FeatureGroup."""
168164

@@ -236,7 +232,7 @@ def test_map_build(self):
236232
def test_tile_attr_unicode(self):
237233
"""Test tile attribution unicode
238234
239-
Test not cover b'юникод'
235+
Test does not cover b'юникод'
240236
because for python 3 bytes can only contain ASCII literal characters.
241237
"""
242238

@@ -315,24 +311,24 @@ def test_custom_icon(self):
315311

316312
def test_global_switches(self):
317313
m = folium.Map(prefer_canvas=True)
318-
assert (m.global_switches.prefer_canvas is True and
319-
m.global_switches.no_touch is False and
320-
m.global_switches.disable_3d is False)
314+
assert m.global_switches.prefer_canvas
315+
assert not m.global_switches.no_touch
316+
assert not m.global_switches.disable_3d
321317

322318
m = folium.Map(no_touch=True)
323-
assert (m.global_switches.prefer_canvas is False and
324-
m.global_switches.no_touch is True and
325-
m.global_switches.disable_3d is False)
319+
assert not m.global_switches.prefer_canvas
320+
assert m.global_switches.no_touch
321+
assert not m.global_switches.disable_3d
326322

327323
m = folium.Map(disable_3d=True)
328-
assert (m.global_switches.prefer_canvas is False and
329-
m.global_switches.no_touch is False and
330-
m.global_switches.disable_3d is True)
324+
assert not m.global_switches.prefer_canvas
325+
assert not m.global_switches.no_touch
326+
assert m.global_switches.disable_3d
331327

332328
m = folium.Map(prefer_canvas=True, no_touch=True, disable_3d=True)
333-
assert (m.global_switches.prefer_canvas is True and
334-
m.global_switches.no_touch is True and
335-
m.global_switches.disable_3d is True)
329+
assert m.global_switches.prefer_canvas
330+
assert m.global_switches.no_touch
331+
assert m.global_switches.disable_3d
336332

337333
@pytest.mark.web
338334
def test_json_request(self):

0 commit comments

Comments
 (0)