mirror of
https://github.com/wassname/geopandas.git
synced 2026-09-11 12:10:59 +08:00
Merge pull request #59 from jtratner/skip-and-guard-geopy
TST/CLN: Guard geopy import and add skip tests if no geopy.
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
from collections import defaultdict
|
||||
|
||||
import fiona
|
||||
import geopy
|
||||
from geopy.geocoders.base import GeocoderResultError
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
from shapely.geometry import Point
|
||||
@@ -40,6 +38,9 @@ def geocode(strings, provider='googlev3', **kwargs):
|
||||
1 1600 Pennsylvania Avenue Northwest, President'... POINT (-77.0365122999999983 38.8978377999999978)
|
||||
|
||||
"""
|
||||
import geopy
|
||||
from geopy.geocoders.base import GeocoderResultError
|
||||
|
||||
if not isinstance(strings, pd.Series):
|
||||
strings = pd.Series(strings)
|
||||
|
||||
|
||||
@@ -4,10 +4,20 @@ import fiona
|
||||
import pandas as pd
|
||||
from shapely.geometry import Point
|
||||
import geopandas as gpd
|
||||
import nose
|
||||
|
||||
from geopandas.geocode import geocode, _prepare_geocode_result
|
||||
|
||||
def _skip_if_no_geopy():
|
||||
try:
|
||||
import geopy
|
||||
except ImportError:
|
||||
raise nose.SkipTest("Geopy not installed. Skipping")
|
||||
|
||||
class TestGeocode(unittest.TestCase):
|
||||
def setUp(self):
|
||||
_skip_if_no_geopy()
|
||||
|
||||
def test_prepare_result(self):
|
||||
# Calls _prepare_result with sample results from the geocoder call
|
||||
# loop
|
||||
|
||||
Reference in New Issue
Block a user