Skip to content

Small cleanups #757

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions folium/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,19 +373,11 @@ def __init__(self, data, style_function=None, name=None,
else:
raise ValueError('Unhandled object {!r}.'.format(data))

if style_function is None:
def style_function(x):
return {}

self.style_function = style_function
self.style_function = style_function or (lambda x: {})

self.highlight = highlight_function is not None

if highlight_function is None:
def highlight_function(x):
return {}

self.highlight_function = highlight_function
self.highlight_function = highlight_function or (lambda x: {})

self.smooth_factor = smooth_factor

Expand Down
34 changes: 15 additions & 19 deletions tests/test_folium.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,12 @@
rootpath = os.path.abspath(os.path.dirname(__file__))

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


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

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


def test_feature_group(self):
"""Test FeatureGroup."""

Expand Down Expand Up @@ -236,7 +232,7 @@ def test_map_build(self):
def test_tile_attr_unicode(self):
"""Test tile attribution unicode

Test not cover b'юникод'
Test does not cover b'юникод'
because for python 3 bytes can only contain ASCII literal characters.
"""

Expand Down Expand Up @@ -315,24 +311,24 @@ def test_custom_icon(self):

def test_global_switches(self):
m = folium.Map(prefer_canvas=True)
assert (m.global_switches.prefer_canvas is True and
m.global_switches.no_touch is False and
m.global_switches.disable_3d is False)
assert m.global_switches.prefer_canvas
assert not m.global_switches.no_touch
assert not m.global_switches.disable_3d

m = folium.Map(no_touch=True)
assert (m.global_switches.prefer_canvas is False and
m.global_switches.no_touch is True and
m.global_switches.disable_3d is False)
assert not m.global_switches.prefer_canvas
assert m.global_switches.no_touch
assert not m.global_switches.disable_3d

m = folium.Map(disable_3d=True)
assert (m.global_switches.prefer_canvas is False and
m.global_switches.no_touch is False and
m.global_switches.disable_3d is True)
assert not m.global_switches.prefer_canvas
assert not m.global_switches.no_touch
assert m.global_switches.disable_3d

m = folium.Map(prefer_canvas=True, no_touch=True, disable_3d=True)
assert (m.global_switches.prefer_canvas is True and
m.global_switches.no_touch is True and
m.global_switches.disable_3d is True)
assert m.global_switches.prefer_canvas
assert m.global_switches.no_touch
assert m.global_switches.disable_3d

@pytest.mark.web
def test_json_request(self):
Expand Down