Skip to content

Commit 8271a80

Browse files
committed
Fix travis
1 parent 9f5e4a9 commit 8271a80

File tree

3 files changed

+49
-58
lines changed

3 files changed

+49
-58
lines changed

.travis.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,15 @@ env:
88
- CONDA="python=3.4"
99

1010
before_install:
11-
- URL=http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh
12-
- wget $URL -O miniconda.sh
11+
- wget http://bit.ly/miniconda -O miniconda.sh
1312
- bash miniconda.sh -b -p $HOME/miniconda
1413
- export PATH="$HOME/miniconda/bin:$PATH"
15-
- hash -r
16-
- conda config --set always_yes yes
17-
- conda update conda
18-
- conda info -a
19-
- travis_retry conda create -n test $CONDA pip jinja2 pandas mock six nose
14+
- conda update --yes conda
15+
- travis_retry conda create --yes -n test $CONDA pip jinja2 pandas mock six nose
2016
- source activate test
2117
- travis_retry pip install vincent
2218

2319
install:
24-
- export PYTHONWARNINGS=all
2520
- python setup.py install
2621

2722
script:

folium/folium.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,8 @@ def fit_bounds(self, bounds, padding_top_left=None,
647647
fit_bounds = self.env.get_template('fit_bounds.js')
648648
fit_bounds_str = fit_bounds.render({
649649
'bounds': json.dumps(bounds),
650-
'fit_bounds_options': json.dumps(fit_bounds_options),
650+
'fit_bounds_options': json.dumps(fit_bounds_options,
651+
sort_keys=True),
651652
})
652653

653654
self.template_vars.update({'fit_bounds': fit_bounds_str})

tests/folium_tests.py

Lines changed: 44 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# -*- coding: utf-8 -*-
2-
'''
2+
"""
33
Folium Tests
44
-------
55
6-
'''
6+
"""
77
import json
88
import mock
99
import pandas as pd
@@ -16,7 +16,7 @@
1616

1717

1818
def setup_data():
19-
'''Import economic data for testing'''
19+
"""Import economic data for testing."""
2020
with open('us-counties.json', 'r') as f:
2121
get_id = json.load(f)
2222

@@ -33,25 +33,25 @@ def setup_data():
3333

3434

3535
def test_get_templates():
36-
'''Test template getting'''
36+
"""Test template getting."""
3737

3838
env = folium.utilities.get_templates()
3939
nt.assert_is_instance(env, jinja2.environment.Environment)
4040

4141

4242
class testFolium(object):
43-
'''Test class for the Folium library'''
43+
"""Test class for the Folium library."""
4444

4545
def setup(self):
46-
'''Setup Folium Map'''
46+
"""Setup Folium Map."""
4747
with mock.patch('folium.folium.uuid4') as uuid4:
4848
uuid4().hex = '0' * 32
4949
self.map = folium.Map(location=[45.5236, -122.6750], width=900,
5050
height=400, max_zoom=20, zoom_start=4)
5151
self.env = Environment(loader=PackageLoader('folium', 'templates'))
5252

5353
def test_init(self):
54-
'''Test map initialization'''
54+
"""Test map initialization."""
5555

5656
assert self.map.map_type == 'base'
5757
assert self.map.mark_cnt == {}
@@ -78,7 +78,7 @@ def test_init(self):
7878
assert self.map.template_vars == tmpl
7979

8080
def test_cloudmade(self):
81-
'''Test cloudmade tiles and the API key'''
81+
"""Test cloudmade tiles and the API key."""
8282

8383
nt.assert_raises(ValueError, callableObj=folium.Map,
8484
location=[45.5236, -122.6750], tiles='cloudmade')
@@ -89,7 +89,7 @@ def test_cloudmade(self):
8989
'/###/997/256/{z}/{x}/{y}.png')
9090

9191
def test_builtin_tile(self):
92-
'''Test custom maptiles'''
92+
"""Test custom maptiles."""
9393

9494
default_tiles = ['OpenStreetMap', 'Stamen Terrain', 'Stamen Toner']
9595
for tiles in default_tiles:
@@ -102,7 +102,7 @@ def test_builtin_tile(self):
102102
assert map.template_vars['attr'] == attr
103103

104104
def test_custom_tile(self):
105-
'''Test custom tile URLs'''
105+
"""Test custom tile URLs."""
106106

107107
url = 'http://{s}.custom_tiles.org/{z}/{x}/{y}.png'
108108
attr = 'Attribution for custom tiles'
@@ -115,7 +115,7 @@ def test_custom_tile(self):
115115
assert map.template_vars['attr'] == attr
116116

117117
def test_wms_layer(self):
118-
'''Test wms layer URLs'''
118+
"""Test WMS layer URLs."""
119119

120120
map = folium.Map(location=[44, -73], zoom_start=3)
121121
wms_url = 'http://gis.srh.noaa.gov/arcgis/services/NDFDTemps/'
@@ -138,7 +138,7 @@ def test_wms_layer(self):
138138
assert map.template_vars['wms_layers'][0] == wms
139139

140140
def test_simple_marker(self):
141-
'''Test simple marker addition'''
141+
"""Test simple marker addition."""
142142

143143
mark_templ = self.env.get_template('simple_marker.js')
144144
popup_templ = self.env.get_template('simple_popup.js')
@@ -148,9 +148,6 @@ def test_simple_marker(self):
148148
mark_1 = mark_templ.render({'marker': 'marker_1', 'lat': 45.50,
149149
'lon': -122.7,
150150
'icon': "{'icon':marker_1_icon}"})
151-
popup_1 = popup_templ.render({'pop_name': 'marker_1',
152-
'pop_txt': json.dumps('Pop Text'),
153-
'width': 300})
154151
assert self.map.template_vars['custom_markers'][0][1] == mark_1
155152
assert self.map.template_vars['custom_markers'][0][2] == ""
156153

@@ -172,7 +169,7 @@ def test_simple_marker(self):
172169
assert self.map.template_vars['custom_markers'][2][2] == nopopup
173170

174171
def test_circle_marker(self):
175-
'''Test circle marker additions'''
172+
"""Test circle marker additions."""
176173

177174
circ_templ = self.env.get_template('circle_marker.js')
178175

@@ -195,7 +192,7 @@ def test_circle_marker(self):
195192
assert self.map.template_vars['markers'][1][0] == circle_2
196193

197194
def test_poly_marker(self):
198-
'''Test polygon marker'''
195+
"""Test polygon marker."""
199196

200197
poly_temp = self.env.get_template('poly_marker.js')
201198

@@ -215,14 +212,14 @@ def test_poly_marker(self):
215212
assert self.map.template_vars['markers'][0][0] == polygon
216213

217214
def test_latlng_pop(self):
218-
'''Test lat/lon popovers'''
215+
"""Test lat/lon popovers."""
219216

220217
self.map.lat_lng_popover()
221218
pop_templ = self.env.get_template('lat_lng_popover.js').render()
222219
assert self.map.template_vars['lat_lng_pop'] == pop_templ
223220

224221
def test_click_for_marker(self):
225-
'''Test click for marker functionality'''
222+
"""Test click for marker functionality."""
226223

227224
# Lat/lon popover.
228225
self.map.click_for_marker()
@@ -238,7 +235,7 @@ def test_click_for_marker(self):
238235
assert self.map.template_vars['click_pop'] == click
239236

240237
def test_vega_popup(self):
241-
'''Test vega popups'''
238+
"""Test vega popups."""
242239

243240
vis = vincent.Bar(width=675 - 75, height=350 - 50, no_data=True)
244241

@@ -253,7 +250,7 @@ def test_vega_popup(self):
253250
assert self.map.template_vars['custom_markers'][0][2] == vega
254251

255252
def test_geo_json(self):
256-
'''Test geojson method'''
253+
"""Test geojson method."""
257254

258255
path = 'us-counties.json'
259256
geo_path = ".defer(d3.json, '{0}')".format(path)
@@ -354,7 +351,7 @@ def test_geo_json(self):
354351
assert templ['topo_convert'][0] == topo_func
355352

356353
def test_map_build(self):
357-
'''Test map build'''
354+
"""Test map build."""
358355

359356
# Standard map.
360357
self.map._build_map()
@@ -377,11 +374,11 @@ def test_map_build(self):
377374
assert self.map.HTML == HTML
378375

379376
def test_tile_attr_unicode(self):
380-
'''Test tile attribution unicode
377+
"""Test tile attribution unicode
381378
382379
Test not cover b'юникод'
383380
because for python 3 bytes can only contain ASCII literal characters.
384-
'''
381+
"""
385382

386383
if not PY3:
387384
map = folium.Map(location=[45.5236, -122.6750],
@@ -396,27 +393,27 @@ def test_tile_attr_unicode(self):
396393
map._build_map()
397394

398395
def test_create_map(self):
399-
'''Test create map'''
396+
"""Test create map."""
400397

401398
map = folium.Map(location=[45.5236, -122.6750],
402399
tiles='test', attr='юникод')
403400

404-
# Add json data
401+
# Add json data.
405402
path = 'us-counties.json'
406403
data = setup_data()
407404
map.geo_json(geo_path=path, data=data,
408405
columns=['FIPS_Code', 'Unemployed_2011'],
409406
key_on='feature.id', fill_color='YlGnBu',
410407
reset=True)
411408

412-
# Add plugins
409+
# Add plugins.
413410
map.polygon_marker(location=[45.5, -122.5])
414411

415-
# Test write
412+
# Test write.
416413
map.create_map()
417414

418415
def test_line(self):
419-
'''Test line'''
416+
"""Test line."""
420417

421418
line_temp = self.env.get_template('polyline.js')
422419

@@ -431,27 +428,26 @@ def test_line(self):
431428
[[45.5238, -122.6750], [45.5238, -122.6751]]
432429
]
433430
line_rendered = line_temp.render({'line': 'line_1',
434-
'locations': locations, 'options': line_opts})
431+
'locations': locations,
432+
'options': line_opts})
435433

436434
self.map.line(locations=locations,
437-
line_color=line_opts['color'],
438-
line_weight=line_opts['weight'],
439-
line_opacity=line_opts['opacity'])
435+
line_color=line_opts['color'],
436+
line_weight=line_opts['weight'],
437+
line_opacity=line_opts['opacity'])
440438
assert self.map.template_vars['lines'][0][0] == line_rendered
441439

442440
def test_multi_polyline(self):
443-
'''Test multi_polyline'''
441+
"""Test multi_polyline."""
444442

445443
multiline_temp = self.env.get_template('multi_polyline.js')
446444

447445
multiline_opts = {'color': 'blue',
448-
'weight': 2,
449-
'opacity': 1}
450-
locations = [
451-
[[45.5236, -122.6750], [45.5236, -122.6751]],
452-
[[45.5237, -122.6750], [45.5237, -122.6751]],
453-
[[45.5238, -122.6750], [45.5238, -122.6751]]
454-
]
446+
'weight': 2,
447+
'opacity': 1}
448+
locations = [[[45.5236, -122.6750], [45.5236, -122.6751]],
449+
[[45.5237, -122.6750], [45.5237, -122.6751]],
450+
[[45.5238, -122.6750], [45.5238, -122.6751]]]
455451
multiline_rendered = multiline_temp.render({'multiline': 'multiline_1',
456452
'locations': locations,
457453
'options': multiline_opts})
@@ -463,23 +459,22 @@ def test_multi_polyline(self):
463459
assert self.map.template_vars['multilines'][0][0] == multiline_rendered
464460

465461
def test_fit_bounds(self):
466-
"""Test fit_bounds"""
462+
"""Test fit_bounds."""
467463
bounds = ((52.193636, -2.221575), (52.636878, -1.139759))
468464
fit_bounds_tpl = self.env.get_template('fit_bounds.js')
469465
fit_bounds_rendered = fit_bounds_tpl.render({
470-
'bounds': json.dumps(bounds),
471-
'fit_bounds_options': {},
472-
})
466+
'bounds': json.dumps(bounds),
467+
'fit_bounds_options': {}, })
473468

474469
self.map.fit_bounds(bounds)
475470
assert self.map.template_vars['fit_bounds'] == fit_bounds_rendered
476471

477472
fit_bounds_tpl = self.env.get_template('fit_bounds.js')
478473
fit_bounds_rendered = fit_bounds_tpl.render({
479-
'bounds': json.dumps(bounds),
480-
'fit_bounds_options': json.dumps({'padding': (3,3), 'maxZoom': 15}),
481-
})
474+
'bounds': json.dumps(bounds),
475+
'fit_bounds_options': json.dumps({'maxZoom': 15,
476+
'padding': (3, 3), }),
477+
}, sort_keys=True)
482478

483479
self.map.fit_bounds(bounds, max_zoom=15, padding=(3, 3))
484480
assert self.map.template_vars['fit_bounds'] == fit_bounds_rendered
485-

0 commit comments

Comments
 (0)