Skip to content

Commit 856be38

Browse files
committed
Run a recent version of yapf against code
1 parent 31cc64b commit 856be38

File tree

4 files changed

+45
-24
lines changed

4 files changed

+45
-24
lines changed

geoip2/mixins.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ class SimpleEquality(object):
99
__metaclass__ = ABCMeta
1010

1111
def __eq__(self, other):
12-
return (isinstance(other, self.__class__) and
13-
self.__dict__ == other.__dict__)
12+
return (isinstance(other, self.__class__)
13+
and self.__dict__ == other.__dict__)
1414

1515
def __ne__(self, other):
1616
return not self.__eq__(other)

tests/database_test.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ def test_asn(self):
8787
self.assertEqual(record.ip_address, ip_address)
8888

8989
self.assertRegex(
90-
str(record),
91-
r'geoip2.models.ASN\(.*1\.128\.0\.0.*\)',
90+
str(record), r'geoip2.models.ASN\(.*1\.128\.0\.0.*\)',
9291
'str representation is correct')
9392

9493
self.assertEqual(record, eval(repr(record)), "ASN repr can be eval'd")
@@ -120,8 +119,7 @@ def test_connection_type(self):
120119
str(record), r'ConnectionType\(\{.*Cable/DSL.*\}\)',
121120
'ConnectionType str representation is reasonable')
122121

123-
self.assertEqual(record,
124-
eval(repr(record)),
122+
self.assertEqual(record, eval(repr(record)),
125123
"ConnectionType repr can be eval'd")
126124

127125
reader.close()
@@ -147,8 +145,8 @@ def test_domain(self):
147145
str(record), r'Domain\(\{.*maxmind.com.*\}\)',
148146
'Domain str representation is reasonable')
149147

150-
self.assertEqual(record,
151-
eval(repr(record)), "Domain repr can be eval'd")
148+
self.assertEqual(record, eval(repr(record)),
149+
"Domain repr can be eval'd")
152150

153151
reader.close()
154152

tests/models_test.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,14 @@ def test_insights_full(self):
163163
r'^geoip2.models.Insights\(\{.*geoname_id.*\}, \[.*en.*\]\)',
164164
'Insights str representation looks reasonable')
165165

166-
self.assertEqual(model,
167-
eval(repr(model)), "Insights repr can be eval'd")
166+
self.assertEqual(model, eval(repr(model)),
167+
"Insights repr can be eval'd")
168168

169169
self.assertRegex(
170170
str(model.location), r'^geoip2.records.Location\(.*longitude=.*\)',
171171
'Location str representation is reasonable')
172172

173-
self.assertEqual(model.location,
174-
eval(repr(model.location)),
173+
self.assertEqual(model.location, eval(repr(model.location)),
175174
"Location repr can be eval'd")
176175

177176
self.assertTrue(model.traits.is_anonymous)

tests/webservice_test.py

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ def test_country_ok(self, mock):
5959
self.base_uri + 'country/1.2.3.4',
6060
json=self.country,
6161
status_code=200,
62-
headers={'Content-Type': self._content_type('country')})
62+
headers={
63+
'Content-Type': self._content_type('country')
64+
})
6365
country = self.client.country('1.2.3.4')
6466
self.assertEqual(
6567
type(country), geoip2.models.Country,
@@ -87,7 +89,9 @@ def test_me(self, mock):
8789
self.base_uri + 'country/me',
8890
json=self.country,
8991
status_code=200,
90-
headers={'Content-Type': self._content_type('country')})
92+
headers={
93+
'Content-Type': self._content_type('country')
94+
})
9195
implicit_me = self.client.country()
9296
self.assertEqual(
9397
type(implicit_me), geoip2.models.Country,
@@ -102,7 +106,9 @@ def test_200_error(self, mock):
102106
mock.get(
103107
self.base_uri + 'country/1.1.1.1',
104108
status_code=200,
105-
headers={'Content-Type': self._content_type('country')})
109+
headers={
110+
'Content-Type': self._content_type('country')
111+
})
106112
with self.assertRaisesRegex(GeoIP2Error,
107113
'could not decode the response as JSON'):
108114
self.client.country('1.1.1.1')
@@ -119,7 +125,9 @@ def test_no_body_error(self, mock):
119125
self.base_uri + 'country/' + '1.2.3.7',
120126
text='',
121127
status_code=400,
122-
headers={'Content-Type': self._content_type('country')})
128+
headers={
129+
'Content-Type': self._content_type('country')
130+
})
123131
with self.assertRaisesRegex(
124132
HTTPError, 'Received a 400 error for .* with no body'):
125133
self.client.country('1.2.3.7')
@@ -130,7 +138,9 @@ def test_weird_body_error(self, mock):
130138
self.base_uri + 'country/' + '1.2.3.8',
131139
text='{"wierd": 42}',
132140
status_code=400,
133-
headers={'Content-Type': self._content_type('country')})
141+
headers={
142+
'Content-Type': self._content_type('country')
143+
})
134144
with self.assertRaisesRegex(HTTPError,
135145
'Response contains JSON but it does not '
136146
'specify code or error keys'):
@@ -142,7 +152,9 @@ def test_bad_body_error(self, mock):
142152
self.base_uri + 'country/' + '1.2.3.9',
143153
text='bad body',
144154
status_code=400,
145-
headers={'Content-Type': self._content_type('country')})
155+
headers={
156+
'Content-Type': self._content_type('country')
157+
})
146158
with self.assertRaisesRegex(
147159
HTTPError, 'it did not include the expected JSON body'):
148160
self.client.country('1.2.3.9')
@@ -159,7 +171,9 @@ def test_300_error(self, mock):
159171
mock.get(
160172
self.base_uri + 'country/' + '1.2.3.11',
161173
status_code=300,
162-
headers={'Content-Type': self._content_type('country')})
174+
headers={
175+
'Content-Type': self._content_type('country')
176+
})
163177
with self.assertRaisesRegex(HTTPError,
164178
'Received a very surprising HTTP status '
165179
'\(300\) for'):
@@ -214,7 +228,9 @@ def _test_error(self, mock, status, error_code, error_class):
214228
self.base_uri + 'country/1.2.3.18',
215229
json=body,
216230
status_code=status,
217-
headers={'Content-Type': self._content_type('country')})
231+
headers={
232+
'Content-Type': self._content_type('country')
233+
})
218234
with self.assertRaisesRegex(error_class, msg):
219235
self.client.country('1.2.3.18')
220236

@@ -227,7 +243,9 @@ def test_unknown_error(self, mock):
227243
self.base_uri + 'country/' + ip,
228244
json=body,
229245
status_code=400,
230-
headers={'Content-Type': self._content_type('country')})
246+
headers={
247+
'Content-Type': self._content_type('country')
248+
})
231249
with self.assertRaisesRegex(InvalidRequestError, msg):
232250
self.client.country(ip)
233251

@@ -237,7 +255,9 @@ def test_request(self, mock):
237255
self.base_uri + 'country/' + '1.2.3.4',
238256
json=self.country,
239257
status_code=200,
240-
headers={'Content-Type': self._content_type('country')})
258+
headers={
259+
'Content-Type': self._content_type('country')
260+
})
241261
self.client.country('1.2.3.4')
242262
request = mock.request_history[-1]
243263

@@ -256,7 +276,9 @@ def test_city_ok(self, mock):
256276
self.base_uri + 'city/' + '1.2.3.4',
257277
json=self.country,
258278
status_code=200,
259-
headers={'Content-Type': self._content_type('city')})
279+
headers={
280+
'Content-Type': self._content_type('city')
281+
})
260282
city = self.client.city('1.2.3.4')
261283
self.assertEqual(
262284
type(city), geoip2.models.City, 'return value of client.city')
@@ -267,7 +289,9 @@ def test_insights_ok(self, mock):
267289
self.base_uri + 'insights/1.2.3.4',
268290
json=self.country,
269291
status_code=200,
270-
headers={'Content-Type': self._content_type('country')})
292+
headers={
293+
'Content-Type': self._content_type('country')
294+
})
271295
insights = self.client.insights('1.2.3.4')
272296
self.assertEqual(
273297
type(insights), geoip2.models.Insights,

0 commit comments

Comments
 (0)