@@ -21,7 +21,9 @@ def test_regex(self):
21
21
<a href="http://some_url">Name</a>
22
22
(<a title="MD5 hash"
23
23
href="{hash_url}">md5</a>)
24
- """ .lstrip ().format (** locals ())
24
+ """ .lstrip ().format (
25
+ ** locals ()
26
+ )
25
27
assert setuptools .package_index .PYPI_MD5 .match (doc )
26
28
27
29
def test_bad_url_bad_port (self ):
@@ -38,9 +40,7 @@ def test_bad_url_typo(self):
38
40
# issue 16
39
41
# easy_install inquant.contentmirror.plone breaks because of a typo
40
42
# in its home URL
41
- index = setuptools .package_index .PackageIndex (
42
- hosts = ('www.example.com' ,)
43
- )
43
+ index = setuptools .package_index .PackageIndex (hosts = ('www.example.com' ,))
44
44
45
45
url = (
46
46
'url:%20https://svn.plone.org/svn'
@@ -54,9 +54,7 @@ def test_bad_url_typo(self):
54
54
assert isinstance (v , urllib .error .HTTPError )
55
55
56
56
def test_bad_url_bad_status_line (self ):
57
- index = setuptools .package_index .PackageIndex (
58
- hosts = ('www.example.com' ,)
59
- )
57
+ index = setuptools .package_index .PackageIndex (hosts = ('www.example.com' ,))
60
58
61
59
def _urlopen (* args ):
62
60
raise http .client .BadStatusLine ('line' )
@@ -74,9 +72,7 @@ def test_bad_url_double_scheme(self):
74
72
"""
75
73
A bad URL with a double scheme should raise a DistutilsError.
76
74
"""
77
- index = setuptools .package_index .PackageIndex (
78
- hosts = ('www.example.com' ,)
79
- )
75
+ index = setuptools .package_index .PackageIndex (hosts = ('www.example.com' ,))
80
76
81
77
# issue 20
82
78
url = 'http://http://svn.pythonpaste.org/Paste/wphp/trunk'
@@ -93,22 +89,17 @@ def test_bad_url_double_scheme(self):
93
89
raise RuntimeError ("Did not raise" )
94
90
95
91
def test_bad_url_screwy_href (self ):
96
- index = setuptools .package_index .PackageIndex (
97
- hosts = ('www.example.com' ,)
98
- )
92
+ index = setuptools .package_index .PackageIndex (hosts = ('www.example.com' ,))
99
93
100
94
# issue #160
101
95
if sys .version_info [0 ] == 2 and sys .version_info [1 ] == 7 :
102
96
# this should not fail
103
97
url = 'http://example.com'
104
- page = ('<a href="http://www.famfamfam.com]('
105
- 'http://www.famfamfam.com/">' )
98
+ page = '<a href="http://www.famfamfam.com](' 'http://www.famfamfam.com/">'
106
99
index .process_index (url , page )
107
100
108
101
def test_url_ok (self ):
109
- index = setuptools .package_index .PackageIndex (
110
- hosts = ('www.example.com' ,)
111
- )
102
+ index = setuptools .package_index .PackageIndex (hosts = ('www.example.com' ,))
112
103
url = 'file:///tmp/test_package_index'
113
104
assert index .url_ok (url , True )
114
105
@@ -169,9 +160,7 @@ def test_egg_fragment(self):
169
160
'b0' ,
170
161
'rc0' ,
171
162
]
172
- post = [
173
- '.post0'
174
- ]
163
+ post = ['.post0' ]
175
164
dev = [
176
165
'.dev0' ,
177
166
]
@@ -186,10 +175,14 @@ def test_egg_fragment(self):
186
175
for e in epoch
187
176
for r in releases
188
177
for p in sum ([pre , post , dev ], ['' ])
189
- for locs in local ]
178
+ for locs in local
179
+ ]
190
180
for v , vc in versions :
191
- dists = list (setuptools .package_index .distros_for_url (
192
- 'http://example.com/example.zip#egg=example-' + v ))
181
+ dists = list (
182
+ setuptools .package_index .distros_for_url (
183
+ 'http://example.com/example.zip#egg=example-' + v
184
+ )
185
+ )
193
186
assert dists [0 ].version == ''
194
187
assert dists [1 ].version == vc
195
188
@@ -204,8 +197,7 @@ def test_download_git_with_rev(self, tmpdir):
204
197
205
198
expected_dir = str (tmpdir / 'project@master' )
206
199
expected = (
207
- 'git clone --quiet '
208
- 'https://github.example/group/project {expected_dir}'
200
+ 'git clone --quiet ' 'https://github.example/group/project {expected_dir}'
209
201
).format (** locals ())
210
202
first_call_args = os_system_mock .call_args_list [0 ][0 ]
211
203
assert first_call_args == (expected ,)
@@ -226,8 +218,7 @@ def test_download_git_no_rev(self, tmpdir):
226
218
227
219
expected_dir = str (tmpdir / 'project' )
228
220
expected = (
229
- 'git clone --quiet '
230
- 'https://github.example/group/project {expected_dir}'
221
+ 'git clone --quiet ' 'https://github.example/group/project {expected_dir}'
231
222
).format (** locals ())
232
223
os_system_mock .assert_called_once_with (expected )
233
224
@@ -243,42 +234,44 @@ def test_download_svn(self, tmpdir):
243
234
244
235
expected_dir = str (tmpdir / 'project' )
245
236
expected = (
246
- 'svn checkout -q '
247
- 'svn+https://svn.example/project {expected_dir}'
237
+ 'svn checkout -q ' 'svn+https://svn.example/project {expected_dir}'
248
238
).format (** locals ())
249
239
os_system_mock .assert_called_once_with (expected )
250
240
251
241
252
242
class TestContentCheckers :
253
243
def test_md5 (self ):
254
244
checker = setuptools .package_index .HashChecker .from_url (
255
- 'http://foo/bar#md5=f12895fdffbd45007040d2e44df98478' )
245
+ 'http://foo/bar#md5=f12895fdffbd45007040d2e44df98478'
246
+ )
256
247
checker .feed ('You should probably not be using MD5' .encode ('ascii' ))
257
248
assert checker .hash .hexdigest () == 'f12895fdffbd45007040d2e44df98478'
258
249
assert checker .is_valid ()
259
250
260
251
def test_other_fragment (self ):
261
252
"Content checks should succeed silently if no hash is present"
262
253
checker = setuptools .package_index .HashChecker .from_url (
263
- 'http://foo/bar#something%20completely%20different' )
254
+ 'http://foo/bar#something%20completely%20different'
255
+ )
264
256
checker .feed ('anything' .encode ('ascii' ))
265
257
assert checker .is_valid ()
266
258
267
259
def test_blank_md5 (self ):
268
260
"Content checks should succeed if a hash is empty"
269
- checker = setuptools .package_index .HashChecker .from_url (
270
- 'http://foo/bar#md5=' )
261
+ checker = setuptools .package_index .HashChecker .from_url ('http://foo/bar#md5=' )
271
262
checker .feed ('anything' .encode ('ascii' ))
272
263
assert checker .is_valid ()
273
264
274
265
def test_get_hash_name_md5 (self ):
275
266
checker = setuptools .package_index .HashChecker .from_url (
276
- 'http://foo/bar#md5=f12895fdffbd45007040d2e44df98478' )
267
+ 'http://foo/bar#md5=f12895fdffbd45007040d2e44df98478'
268
+ )
277
269
assert checker .hash_name == 'md5'
278
270
279
271
def test_report (self ):
280
272
checker = setuptools .package_index .HashChecker .from_url (
281
- 'http://foo/bar#md5=f12895fdffbd45007040d2e44df98478' )
273
+ 'http://foo/bar#md5=f12895fdffbd45007040d2e44df98478'
274
+ )
282
275
rep = checker .report (lambda x : x , 'My message about %s' )
283
276
assert rep == 'My message about md5'
284
277
@@ -287,8 +280,8 @@ def test_report(self):
287
280
def temp_home (tmpdir , monkeypatch ):
288
281
key = (
289
282
'USERPROFILE'
290
- if platform .system () == 'Windows' and sys .version_info > (3 , 8 ) else
291
- 'HOME'
283
+ if platform .system () == 'Windows' and sys .version_info > (3 , 8 )
284
+ else 'HOME'
292
285
)
293
286
294
287
monkeypatch .setitem (os .environ , key , str (tmpdir ))
@@ -298,12 +291,16 @@ def temp_home(tmpdir, monkeypatch):
298
291
class TestPyPIConfig :
299
292
def test_percent_in_password (self , temp_home ):
300
293
pypirc = temp_home / '.pypirc'
301
- pypirc .write (DALS ("""
294
+ pypirc .write (
295
+ DALS (
296
+ """
302
297
[pypi]
303
298
repository=https://pypi.org
304
299
username=jaraco
305
300
password=pity%
306
- """ ))
301
+ """
302
+ )
303
+ )
307
304
cfg = setuptools .package_index .PyPIConfig ()
308
305
cred = cfg .creds_by_repository ['https://pypi.org' ]
309
306
assert cred .username == 'jaraco'
0 commit comments