Skip to content

Commit c3ab0a0

Browse files
authored
Merge pull request #7552 from chrahunt/refactor/cleanup-wheel-install-tests
Make wheel install test packages more explicit
2 parents b263fcc + f5684ed commit c3ab0a0

File tree

1 file changed

+87
-32
lines changed

1 file changed

+87
-32
lines changed

tests/functional/test_install_wheel.py

+87-32
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,16 @@ def test_install_from_broken_wheel(script, data):
4141
editable=False)
4242

4343

44-
def test_basic_install_from_wheel(script, data):
44+
def test_basic_install_from_wheel(script, shared_data, tmpdir):
4545
"""
4646
Test installing from a wheel (that has a script)
4747
"""
48+
shutil.copy(
49+
shared_data.packages / "has.script-1.0-py2.py3-none-any.whl", tmpdir
50+
)
4851
result = script.pip(
4952
'install', 'has.script==1.0', '--no-index',
50-
'--find-links=' + data.find_links,
53+
'--find-links', tmpdir,
5154
)
5255
dist_info_folder = script.site_packages / 'has.script-1.0.dist-info'
5356
assert dist_info_folder in result.files_created, (dist_info_folder,
@@ -57,13 +60,19 @@ def test_basic_install_from_wheel(script, data):
5760
assert script_file in result.files_created
5861

5962

60-
def test_basic_install_from_wheel_with_extras(script, data):
63+
def test_basic_install_from_wheel_with_extras(script, shared_data, tmpdir):
6164
"""
6265
Test installing from a wheel with extras.
6366
"""
67+
shutil.copy(
68+
shared_data.packages / "complex_dist-0.1-py2.py3-none-any.whl", tmpdir
69+
)
70+
shutil.copy(
71+
shared_data.packages / "simple.dist-0.1-py2.py3-none-any.whl", tmpdir
72+
)
6473
result = script.pip(
6574
'install', 'complex-dist[simple]', '--no-index',
66-
'--find-links=' + data.find_links,
75+
'--find-links', tmpdir,
6776
)
6877
dist_info_folder = script.site_packages / 'complex_dist-0.1.dist-info'
6978
assert dist_info_folder in result.files_created, (dist_info_folder,
@@ -110,14 +119,17 @@ def test_install_from_wheel_with_headers(script, data):
110119
result.stdout)
111120

112121

113-
def test_install_wheel_with_target(script, data, with_wheel):
122+
def test_install_wheel_with_target(script, shared_data, with_wheel, tmpdir):
114123
"""
115124
Test installing a wheel using pip install --target
116125
"""
126+
shutil.copy(
127+
shared_data.packages / "simple.dist-0.1-py2.py3-none-any.whl", tmpdir
128+
)
117129
target_dir = script.scratch_path / 'target'
118130
result = script.pip(
119131
'install', 'simple.dist==0.1', '-t', target_dir,
120-
'--no-index', '--find-links=' + data.find_links,
132+
'--no-index', '--find-links', tmpdir,
121133
)
122134
assert Path('scratch') / 'target' / 'simpledist' in result.files_created, (
123135
str(result)
@@ -159,55 +171,63 @@ def test_install_wheel_with_target_and_data_files(script, data, with_wheel):
159171
not in result.files_created), str(result)
160172

161173

162-
def test_install_wheel_with_root(script, data):
174+
def test_install_wheel_with_root(script, shared_data, tmpdir):
163175
"""
164176
Test installing a wheel using pip install --root
165177
"""
166178
root_dir = script.scratch_path / 'root'
179+
shutil.copy(
180+
shared_data.packages / "simple.dist-0.1-py2.py3-none-any.whl", tmpdir
181+
)
167182
result = script.pip(
168183
'install', 'simple.dist==0.1', '--root', root_dir,
169-
'--no-index', '--find-links=' + data.find_links,
184+
'--no-index', '--find-links', tmpdir,
170185
)
171186
assert Path('scratch') / 'root' in result.files_created
172187

173188

174-
def test_install_wheel_with_prefix(script, data):
189+
def test_install_wheel_with_prefix(script, shared_data, tmpdir):
175190
"""
176191
Test installing a wheel using pip install --prefix
177192
"""
178193
prefix_dir = script.scratch_path / 'prefix'
194+
shutil.copy(
195+
shared_data.packages / "simple.dist-0.1-py2.py3-none-any.whl", tmpdir
196+
)
179197
result = script.pip(
180198
'install', 'simple.dist==0.1', '--prefix', prefix_dir,
181-
'--no-index', '--find-links=' + data.find_links,
199+
'--no-index', '--find-links', tmpdir,
182200
)
183201
lib = distutils.sysconfig.get_python_lib(prefix=Path('scratch') / 'prefix')
184202
assert lib in result.files_created, str(result)
185203

186204

187-
def test_install_from_wheel_installs_deps(script, data):
205+
def test_install_from_wheel_installs_deps(script, data, tmpdir):
188206
"""
189207
Test can install dependencies of wheels
190208
"""
191209
# 'requires_source' depends on the 'source' project
192210
package = data.packages.joinpath(
193211
"requires_source-1.0-py2.py3-none-any.whl"
194212
)
213+
shutil.copy(data.packages / "source-1.0.tar.gz", tmpdir)
195214
result = script.pip(
196-
'install', '--no-index', '--find-links', data.find_links, package,
215+
'install', '--no-index', '--find-links', tmpdir, package,
197216
)
198217
result.assert_installed('source', editable=False)
199218

200219

201-
def test_install_from_wheel_no_deps(script, data):
220+
def test_install_from_wheel_no_deps(script, data, tmpdir):
202221
"""
203222
Test --no-deps works with wheel installs
204223
"""
205224
# 'requires_source' depends on the 'source' project
206225
package = data.packages.joinpath(
207226
"requires_source-1.0-py2.py3-none-any.whl"
208227
)
228+
shutil.copy(data.packages / "source-1.0.tar.gz", tmpdir)
209229
result = script.pip(
210-
'install', '--no-index', '--find-links', data.find_links, '--no-deps',
230+
'install', '--no-index', '--find-links', tmpdir, '--no-deps',
211231
package,
212232
)
213233
pkg_folder = script.site_packages / 'source'
@@ -232,27 +252,34 @@ def test_wheel_record_lines_in_deterministic_order(script, data):
232252

233253

234254
@pytest.mark.incompatible_with_test_venv
235-
def test_install_user_wheel(script, data, with_wheel):
255+
def test_install_user_wheel(script, shared_data, with_wheel, tmpdir):
236256
"""
237257
Test user install from wheel (that has a script)
238258
"""
259+
shutil.copy(
260+
shared_data.packages / "has.script-1.0-py2.py3-none-any.whl", tmpdir
261+
)
239262
result = script.pip(
240263
'install', 'has.script==1.0', '--user', '--no-index',
241-
'--find-links=' + data.find_links,
264+
'--find-links', tmpdir,
242265
)
243266
egg_info_folder = script.user_site / 'has.script-1.0.dist-info'
244267
assert egg_info_folder in result.files_created, str(result)
245268
script_file = script.user_bin / 'script.py'
246269
assert script_file in result.files_created, str(result)
247270

248271

249-
def test_install_from_wheel_gen_entrypoint(script, data):
272+
def test_install_from_wheel_gen_entrypoint(script, shared_data, tmpdir):
250273
"""
251274
Test installing scripts (entry points are generated)
252275
"""
276+
shutil.copy(
277+
shared_data.packages / "script.wheel1a-0.1-py2.py3-none-any.whl",
278+
tmpdir,
279+
)
253280
result = script.pip(
254281
'install', 'script.wheel1a==0.1', '--no-index',
255-
'--find-links=' + data.find_links,
282+
'--find-links', tmpdir,
256283
)
257284
if os.name == 'nt':
258285
wrapper_file = script.bin / 't1.exe'
@@ -264,13 +291,20 @@ def test_install_from_wheel_gen_entrypoint(script, data):
264291
assert bool(os.access(script.base_path / wrapper_file, os.X_OK))
265292

266293

267-
def test_install_from_wheel_gen_uppercase_entrypoint(script, data):
294+
def test_install_from_wheel_gen_uppercase_entrypoint(
295+
script, shared_data, tmpdir
296+
):
268297
"""
269298
Test installing scripts with uppercase letters in entry point names
270299
"""
300+
shutil.copy(
301+
shared_data.packages /
302+
"console_scripts_uppercase-1.0-py2.py3-none-any.whl",
303+
tmpdir,
304+
)
271305
result = script.pip(
272306
'install', 'console-scripts-uppercase==1.0', '--no-index',
273-
'--find-links=' + data.find_links,
307+
'--find-links', tmpdir,
274308
)
275309
if os.name == 'nt':
276310
# Case probably doesn't make any difference on NT
@@ -283,13 +317,17 @@ def test_install_from_wheel_gen_uppercase_entrypoint(script, data):
283317
assert bool(os.access(script.base_path / wrapper_file, os.X_OK))
284318

285319

286-
def test_install_from_wheel_with_legacy(script, data):
320+
def test_install_from_wheel_with_legacy(script, shared_data, tmpdir):
287321
"""
288322
Test installing scripts (legacy scripts are preserved)
289323
"""
324+
shutil.copy(
325+
shared_data.packages / "script.wheel2a-0.1-py2.py3-none-any.whl",
326+
tmpdir,
327+
)
290328
result = script.pip(
291329
'install', 'script.wheel2a==0.1', '--no-index',
292-
'--find-links=' + data.find_links,
330+
'--find-links', tmpdir,
293331
)
294332

295333
legacy_file1 = script.bin / 'testscript1.bat'
@@ -299,14 +337,19 @@ def test_install_from_wheel_with_legacy(script, data):
299337
assert legacy_file2 in result.files_created
300338

301339

302-
def test_install_from_wheel_no_setuptools_entrypoint(script, data):
340+
def test_install_from_wheel_no_setuptools_entrypoint(
341+
script, shared_data, tmpdir
342+
):
303343
"""
304344
Test that when we generate scripts, any existing setuptools wrappers in
305345
the wheel are skipped.
306346
"""
347+
shutil.copy(
348+
shared_data.packages / "script.wheel1-0.1-py2.py3-none-any.whl", tmpdir
349+
)
307350
result = script.pip(
308351
'install', 'script.wheel1==0.1', '--no-index',
309-
'--find-links=' + data.find_links,
352+
'--find-links', tmpdir,
310353
)
311354
if os.name == 'nt':
312355
wrapper_file = script.bin / 't1.exe'
@@ -323,14 +366,17 @@ def test_install_from_wheel_no_setuptools_entrypoint(script, data):
323366
assert wrapper_helper not in result.files_created
324367

325368

326-
def test_skipping_setuptools_doesnt_skip_legacy(script, data):
369+
def test_skipping_setuptools_doesnt_skip_legacy(script, shared_data, tmpdir):
327370
"""
328371
Test installing scripts (legacy scripts are preserved even when we skip
329372
setuptools wrappers)
330373
"""
374+
shutil.copy(
375+
shared_data.packages / "script.wheel2-0.1-py2.py3-none-any.whl", tmpdir
376+
)
331377
result = script.pip(
332378
'install', 'script.wheel2==0.1', '--no-index',
333-
'--find-links=' + data.find_links,
379+
'--find-links', tmpdir,
334380
)
335381

336382
legacy_file1 = script.bin / 'testscript1.bat'
@@ -342,13 +388,16 @@ def test_skipping_setuptools_doesnt_skip_legacy(script, data):
342388
assert wrapper_helper not in result.files_created
343389

344390

345-
def test_install_from_wheel_gui_entrypoint(script, data):
391+
def test_install_from_wheel_gui_entrypoint(script, shared_data, tmpdir):
346392
"""
347393
Test installing scripts (gui entry points are generated)
348394
"""
395+
shutil.copy(
396+
shared_data.packages / "script.wheel3-0.1-py2.py3-none-any.whl", tmpdir
397+
)
349398
result = script.pip(
350399
'install', 'script.wheel3==0.1', '--no-index',
351-
'--find-links=' + data.find_links,
400+
'--find-links', tmpdir,
352401
)
353402
if os.name == 'nt':
354403
wrapper_file = script.bin / 't1.exe'
@@ -357,13 +406,16 @@ def test_install_from_wheel_gui_entrypoint(script, data):
357406
assert wrapper_file in result.files_created
358407

359408

360-
def test_wheel_compiles_pyc(script, data):
409+
def test_wheel_compiles_pyc(script, shared_data, tmpdir):
361410
"""
362411
Test installing from wheel with --compile on
363412
"""
413+
shutil.copy(
414+
shared_data.packages / "simple.dist-0.1-py2.py3-none-any.whl", tmpdir
415+
)
364416
script.pip(
365417
"install", "--compile", "simple.dist==0.1", "--no-index",
366-
"--find-links=" + data.find_links
418+
"--find-links", tmpdir,
367419
)
368420
# There are many locations for the __init__.pyc file so attempt to find
369421
# any of them
@@ -378,13 +430,16 @@ def test_wheel_compiles_pyc(script, data):
378430
assert any(exists)
379431

380432

381-
def test_wheel_no_compiles_pyc(script, data):
433+
def test_wheel_no_compiles_pyc(script, shared_data, tmpdir):
382434
"""
383435
Test installing from wheel with --compile on
384436
"""
437+
shutil.copy(
438+
shared_data.packages / "simple.dist-0.1-py2.py3-none-any.whl", tmpdir
439+
)
385440
script.pip(
386441
"install", "--no-compile", "simple.dist==0.1", "--no-index",
387-
"--find-links=" + data.find_links
442+
"--find-links", tmpdir,
388443
)
389444
# There are many locations for the __init__.pyc file so attempt to find
390445
# any of them

0 commit comments

Comments
 (0)