1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
https://github.com/geopy/geopy/commit/6c9714c480d62dcd04d514dcad10785d5a0816c2
diff --git a/test/geocoders/arcgis.py b/test/geocoders/arcgis.py
index fdca58c..b154a60 100644
--- a/test/geocoders/arcgis.py
+++ b/test/geocoders/arcgis.py
@@ -7,6 +7,10 @@
from test.geocoders.util import GeocoderTestBase, env
+@unittest.skipUnless( # pylint: disable=R0904,C0111
+ bool(env.get('ARCGIS_USERNAME')),
+ "No ARCGIS_USERNAME env variable set"
+)
class ArcGISTestCase(GeocoderTestBase):
@classmethod
diff --git a/test/geocoders/baidu.py b/test/geocoders/baidu.py
index 8ba249c..827ab12 100644
--- a/test/geocoders/baidu.py
+++ b/test/geocoders/baidu.py
@@ -6,8 +6,8 @@
from test.geocoders.util import GeocoderTestBase, env
-@unittest.skipUnless( # pylint: disable=R0904,C0111
- env['BAIDU_KEY'] is not None,
+@unittest.skipUnless( # pylint: disable=R0904,C0111
+ bool(env.get('BAIDU_KEY')),
"No BAIDU_KEY env variable set"
)
class BaiduTestCase(GeocoderTestBase):
diff --git a/test/geocoders/bing.py b/test/geocoders/bing.py
index 17b1aae..d23e99b 100644
--- a/test/geocoders/bing.py
+++ b/test/geocoders/bing.py
@@ -6,8 +6,8 @@
from test.geocoders.util import GeocoderTestBase, env
-@unittest.skipUnless( # pylint: disable=R0904,C0111
- env['BING_KEY'] is not None,
+@unittest.skipUnless( # pylint: disable=R0904,C0111
+ bool(env.get('BING_KEY')),
"No BING_KEY env variable set"
)
class BingTestCase(GeocoderTestBase):
diff --git a/test/geocoders/dotus.py b/test/geocoders/dotus.py
index e777278..d2bbfa2 100644
--- a/test/geocoders/dotus.py
+++ b/test/geocoders/dotus.py
@@ -5,9 +5,9 @@
from geopy.geocoders import GeocoderDotUS
from test.geocoders.util import GeocoderTestBase, env
-@unittest.skipUnless( # pylint: disable=R0904,C0111
- env['GEOCODERDOTUS_USERNAME'] is not None and \
- env['GEOCODERDOTUS_PASSWORD'] is not None,
+@unittest.skipUnless( # pylint: disable=R0904,C0111
+ bool(env.get('GEOCODERDOTUS_USERNAME')) and \
+ bool(env.get('GEOCODERDOTUS_PASSWORD')),
"No GEOCODERDOTUS_USERNAME and GEOCODERDOTUS_PASSWORD env variables set"
)
class GeocoderDotUSTestCase(GeocoderTestBase): # pylint: disable=R0904,C0111
diff --git a/test/geocoders/geocodefarm.py b/test/geocoders/geocodefarm.py
index 151bac6..ffa28a4 100644
--- a/test/geocoders/geocodefarm.py
+++ b/test/geocoders/geocodefarm.py
@@ -8,8 +8,8 @@
from test.geocoders.util import GeocoderTestBase, env
-@unittest.skipUnless( # pylint: disable=R0904,C0111
- env['GEOCODEFARM_KEY'] is not None,
+@unittest.skipUnless( # pylint: disable=R0904,C0111
+ bool(env.get('GEOCODEFARM_KEY')),
"GEOCODEFARM_KEY env variable not set"
)
class GeocodeFarmTestCase(GeocoderTestBase): # pylint: disable=R0904,C0111
diff --git a/test/geocoders/geonames.py b/test/geocoders/geonames.py
index 7ff6f11..3dcc3b4 100644
--- a/test/geocoders/geonames.py
+++ b/test/geocoders/geonames.py
@@ -4,21 +4,23 @@
from geopy.geocoders import GeoNames
from test.geocoders.util import GeocoderTestBase, env
-@unittest.skipUnless( # pylint: disable=R0904,C0111
- env['GEONAMES_USERNAME'] is not None,
+
+@unittest.skipUnless( # pylint: disable=R0904,C0111
+ bool(env.get('GEONAMES_USERNAME')),
"No GEONAMES_USERNAME env variable set"
)
class GeoNamesTestCase(GeocoderTestBase):
@classmethod
def setUpClass(cls):
- cls.geocoder = GeoNames(username=env['GEONAMES_USERNAME'])
cls.delta = 0.04
def test_unicode_name(self):
"""
GeoNames.geocode unicode
"""
+ # work around ConfigurationError raised in GeoNames init
+ self.geocoder = GeoNames(username=env['GEONAMES_USERNAME'])
self.geocode_run(
{"query": u"\u6545\u5bab"},
{"latitude": 30.90097, "longitude": 118.49436},
diff --git a/test/geocoders/mapquest.py b/test/geocoders/mapquest.py
index eb12781..03ba4d8 100644
--- a/test/geocoders/mapquest.py
+++ b/test/geocoders/mapquest.py
@@ -5,8 +5,8 @@
from test.geocoders.util import GeocoderTestBase, env
-@unittest.skipUnless( # pylint: disable=R0904,C0111
- env['MAPQUEST_KEY'] is not None,
+@unittest.skipUnless( # pylint: disable=R0904,C0111
+ bool(env.get('MAPQUEST_KEY')),
"No MAPQUEST_KEY env variable set"
)
class MapQuestTestCase(GeocoderTestBase):
diff --git a/test/geocoders/opencage.py b/test/geocoders/opencage.py
index c00114f..eb65000 100644
--- a/test/geocoders/opencage.py
+++ b/test/geocoders/opencage.py
@@ -5,8 +5,8 @@
from test.geocoders.util import GeocoderTestBase, env
-@unittest.skipUnless( # pylint: disable=R0904,C0111
- env['OPENCAGE_KEY'] is not None,
+@unittest.skipUnless( # pylint: disable=R0904,C0111
+ bool(env.get('OPENCAGE_KEY')),
"No OPENCAGE_KEY env variables set"
)
class OpenCageTestCase(GeocoderTestBase):
diff --git a/test/geocoders/placefinder.py b/test/geocoders/placefinder.py
index 3bf0a66..ed3304f 100644
--- a/test/geocoders/placefinder.py
+++ b/test/geocoders/placefinder.py
@@ -6,8 +6,8 @@
from test.geocoders.util import GeocoderTestBase, env
-@unittest.skipUnless( # pylint: disable=R0904,C0111
- env['YAHOO_KEY'] is not None and env['YAHOO_SECRET'] is not None,
+@unittest.skipUnless( # pylint: disable=R0904,C0111
+ bool(env.get('YAHOO_KEY')) and bool(env.get('YAHOO_SECRET')),
"YAHOO_KEY and YAHOO_SECRET env variables not set"
)
class YahooPlaceFinderTestCase(GeocoderTestBase): # pylint: disable=R0904,C0111
diff --git a/test/geocoders/smartystreets.py b/test/geocoders/smartystreets.py
index 83f3b34..ed9e7f2 100644
--- a/test/geocoders/smartystreets.py
+++ b/test/geocoders/smartystreets.py
@@ -5,17 +5,19 @@
from test.geocoders.util import GeocoderTestBase, env
-@unittest.skipUnless( # pylint: disable=R0904,C0111
- env['LIVESTREETS_AUTH_KEY'] is not None,
+@unittest.skipUnless( # pylint: disable=R0904,C0111
+ bool(env.get('LIVESTREETS_AUTH_KEY')),
"No LIVESTREETS_AUTH_KEY env variable set"
)
class LiveAddressTestCase(GeocoderTestBase):
- def setUp(self):
- self.geocoder = LiveAddress(
+
+ @classmethod
+ def setUpClass(cls):
+ cls.geocoder = LiveAddress(
auth_token=env['LIVESTREETS_AUTH_KEY'],
scheme='http'
)
- self.delta = 0.04
+ cls.delta = 0.04
def test_geocode(self):
"""
diff --git a/test/geocoders/util.py b/test/geocoders/util.py
index 4a130f1..7de103d 100644
--- a/test/geocoders/util.py
+++ b/test/geocoders/util.py
@@ -12,6 +12,9 @@
env.update(json.loads(fp.read()))
except IOError:
keys = (
+ 'ARCGIS_USERNAME',
+ 'ARCGIS_PASSWORD',
+ 'ARCGIS_REFERER',
'YAHOO_KEY',
'YAHOO_SECRET',
'BING_KEY',
|