@@ -49,20 +49,20 @@ def fn(v):
49
49
return factory
50
50
51
51
52
- @pytest .mark .parametrize ('use_curl ' , [True , False ])
53
- def test_urlfetchstrategy_sans_url (use_curl ):
52
+ @pytest .mark .parametrize ('_fetch_method ' , ['curl' , 'urllib' ])
53
+ def test_urlfetchstrategy_sans_url (_fetch_method ):
54
54
"""Ensure constructor with no URL fails."""
55
- with spack .config .override ('config:use_curl ' , use_curl ):
55
+ with spack .config .override ('config:url_fetch_method ' , _fetch_method ):
56
56
with pytest .raises (ValueError ):
57
57
with fs .URLFetchStrategy (None ):
58
58
pass
59
59
60
60
61
- @pytest .mark .parametrize ('use_curl ' , [True , False ])
62
- def test_urlfetchstrategy_bad_url (tmpdir , use_curl ):
61
+ @pytest .mark .parametrize ('_fetch_method ' , ['curl' , 'urllib' ])
62
+ def test_urlfetchstrategy_bad_url (tmpdir , _fetch_method ):
63
63
"""Ensure fetch with bad URL fails as expected."""
64
64
testpath = str (tmpdir )
65
- with spack .config .override ('config:use_curl ' , use_curl ):
65
+ with spack .config .override ('config:url_fetch_method ' , _fetch_method ):
66
66
with pytest .raises (fs .FailedDownloadError ):
67
67
fetcher = fs .URLFetchStrategy (url = 'file:///does-not-exist' )
68
68
assert fetcher is not None
@@ -75,7 +75,7 @@ def test_urlfetchstrategy_bad_url(tmpdir, use_curl):
75
75
76
76
def test_fetch_options (tmpdir , mock_archive ):
77
77
testpath = str (tmpdir )
78
- with spack .config .override ('config:use_curl ' , True ):
78
+ with spack .config .override ('config:url_fetch_method ' , 'curl' ):
79
79
fetcher = fs .URLFetchStrategy (url = mock_archive .url ,
80
80
fetch_options = {'cookie' : 'True' ,
81
81
'timeout' : 10 })
@@ -87,11 +87,11 @@ def test_fetch_options(tmpdir, mock_archive):
87
87
fetcher .fetch ()
88
88
89
89
90
- @pytest .mark .parametrize ('use_curl ' , [True , False ])
91
- def test_archive_file_errors (tmpdir , mock_archive , use_curl ):
90
+ @pytest .mark .parametrize ('_fetch_method ' , ['curl' , 'urllib' ])
91
+ def test_archive_file_errors (tmpdir , mock_archive , _fetch_method ):
92
92
"""Ensure FetchStrategy commands may only be used as intended"""
93
93
testpath = str (tmpdir )
94
- with spack .config .override ('config:use_curl ' , use_curl ):
94
+ with spack .config .override ('config:url_fetch_method ' , _fetch_method ):
95
95
fetcher = fs .URLFetchStrategy (url = mock_archive .url )
96
96
assert fetcher is not None
97
97
with pytest .raises (fs .FailedDownloadError ):
@@ -112,7 +112,7 @@ def test_archive_file_errors(tmpdir, mock_archive, use_curl):
112
112
113
113
114
114
@pytest .mark .parametrize ('secure' , [True , False ])
115
- @pytest .mark .parametrize ('use_curl ' , [True , False ])
115
+ @pytest .mark .parametrize ('_fetch_method ' , ['curl' , 'urllib' ])
116
116
@pytest .mark .parametrize ('mock_archive' ,
117
117
[('.tar.gz' , 'z' ), ('.tgz' , 'z' ),
118
118
('.tar.bz2' , 'j' ), ('.tbz2' , 'j' ),
@@ -121,7 +121,7 @@ def test_archive_file_errors(tmpdir, mock_archive, use_curl):
121
121
def test_fetch (
122
122
mock_archive ,
123
123
secure ,
124
- use_curl ,
124
+ _fetch_method ,
125
125
checksum_type ,
126
126
config ,
127
127
mutable_mock_repo
@@ -147,7 +147,7 @@ def test_fetch(
147
147
# Enter the stage directory and check some properties
148
148
with pkg .stage :
149
149
with spack .config .override ('config:verify_ssl' , secure ):
150
- with spack .config .override ('config:use_curl ' , use_curl ):
150
+ with spack .config .override ('config:url_fetch_method ' , _fetch_method ):
151
151
pkg .do_stage ()
152
152
with working_dir (pkg .stage .source_path ):
153
153
assert os .path .exists ('configure' )
@@ -168,13 +168,13 @@ def test_fetch(
168
168
('url-list-test @3.0a1' , 'foo-3.0a1.tar.gz' , 'abc30a1' ),
169
169
('url-list-test @4.5-rc5' , 'foo-4.5-rc5.tar.gz' , 'abc45rc5' ),
170
170
])
171
- @pytest .mark .parametrize ('use_curl ' , [True , False ])
172
- def test_from_list_url (mock_packages , config , spec , url , digest , use_curl ):
171
+ @pytest .mark .parametrize ('_fetch_method ' , ['curl' , 'urllib' ])
172
+ def test_from_list_url (mock_packages , config , spec , url , digest , _fetch_method ):
173
173
"""
174
174
Test URLs in the url-list-test package, which means they should
175
175
have checksums in the package.
176
176
"""
177
- with spack .config .override ('config:use_curl ' , use_curl ):
177
+ with spack .config .override ('config:url_fetch_method ' , _fetch_method ):
178
178
specification = Spec (spec ).concretized ()
179
179
pkg = spack .repo .get (specification )
180
180
fetch_strategy = fs .from_list_url (pkg )
@@ -187,10 +187,10 @@ def test_from_list_url(mock_packages, config, spec, url, digest, use_curl):
187
187
assert fetch_strategy .extra_options == {'timeout' : 60 }
188
188
189
189
190
- @pytest .mark .parametrize ('use_curl ' , [True , False ])
191
- def test_from_list_url_unspecified (mock_packages , config , use_curl ):
190
+ @pytest .mark .parametrize ('_fetch_method ' , ['curl' , 'urllib' ])
191
+ def test_from_list_url_unspecified (mock_packages , config , _fetch_method ):
192
192
"""Test non-specific URLs from the url-list-test package."""
193
- with spack .config .override ('config:use_curl ' , use_curl ):
193
+ with spack .config .override ('config:url_fetch_method ' , _fetch_method ):
194
194
pkg = spack .repo .get ('url-list-test' )
195
195
196
196
spec = Spec ('url-list-test @2.0.0' ).concretized ()
@@ -236,7 +236,7 @@ def is_true():
236
236
237
237
monkeypatch .setattr (sys .stdout , 'isatty' , is_true )
238
238
monkeypatch .setattr (tty , 'msg_enabled' , is_true )
239
- with spack .config .override ('config:use_curl ' , True ):
239
+ with spack .config .override ('config:url_fetch_method ' , 'curl' ):
240
240
fetcher = fs .URLFetchStrategy (mock_archive .url )
241
241
with Stage (fetcher , path = testpath ) as stage :
242
242
assert fetcher .archive_file is None
@@ -246,10 +246,10 @@ def is_true():
246
246
assert '##### 100' in status
247
247
248
248
249
- @pytest .mark .parametrize ('use_curl ' , [True , False ])
250
- def test_url_extra_fetch (tmpdir , mock_archive , use_curl ):
249
+ @pytest .mark .parametrize ('_fetch_method ' , ['curl' , 'urllib' ])
250
+ def test_url_extra_fetch (tmpdir , mock_archive , _fetch_method ):
251
251
"""Ensure a fetch after downloading is effectively a no-op."""
252
- with spack .config .override ('config:use_curl ' , use_curl ):
252
+ with spack .config .override ('config:url_fetch_method ' , _fetch_method ):
253
253
testpath = str (tmpdir )
254
254
fetcher = fs .URLFetchStrategy (mock_archive .url )
255
255
with Stage (fetcher , path = testpath ) as stage :
@@ -267,12 +267,12 @@ def test_url_extra_fetch(tmpdir, mock_archive, use_curl):
267
267
['https://ftpmirror.gnu.org/autoconf/autoconf-2.62.tar.gz' ,
268
268
'https://ftp.gnu.org/gnu/autoconf/autoconf-2.62.tar.gz' ])
269
269
])
270
- @pytest .mark .parametrize ('use_curl ' , [True , False ])
271
- def test_candidate_urls (pkg_factory , url , urls , version , expected , use_curl ):
270
+ @pytest .mark .parametrize ('_fetch_method ' , ['curl' , 'urllib' ])
271
+ def test_candidate_urls (pkg_factory , url , urls , version , expected , _fetch_method ):
272
272
"""Tests that candidate urls include mirrors and that they go through
273
273
pattern matching and substitution for versions.
274
274
"""
275
- with spack .config .override ('config:use_curl ' , use_curl ):
275
+ with spack .config .override ('config:url_fetch_method ' , _fetch_method ):
276
276
pkg = pkg_factory (url , urls )
277
277
f = fs ._from_merged_attrs (fs .URLFetchStrategy , pkg , version )
278
278
assert f .candidate_urls == expected
@@ -298,7 +298,7 @@ def _which(*args, **kwargs):
298
298
299
299
testpath = str (tmpdir )
300
300
url = 'http://github.com/spack/spack'
301
- with spack .config .override ('config:use_curl ' , True ):
301
+ with spack .config .override ('config:url_fetch_method ' , 'curl' ):
302
302
fetcher = fs .URLFetchStrategy (url = url )
303
303
assert fetcher is not None
304
304
with pytest .raises (TypeError , match = 'object is not callable' ):
0 commit comments