Skip to content

Commit dffe746

Browse files
committed
test: Migrate some functional tests to new APIs
1 parent 84584b7 commit dffe746

File tree

3 files changed

+27
-80
lines changed

3 files changed

+27
-80
lines changed

tests/functional/test_check.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -333,14 +333,7 @@ def test_check_unsupported(
333333
script.scratch_path.joinpath("base-0.1.0-py2.py3-none-any.whl").write_bytes(
334334
create_really_basic_wheel("base", "0.1.0")
335335
)
336-
script.pip(
337-
"install",
338-
"--no-cache-dir",
339-
"--no-index",
340-
"--find-links",
341-
script.scratch_path,
342-
"base==0.1.0",
343-
)
336+
script.pip_install_local("base==0.1.0", find_links=script.scratch_path)
344337
with open(
345338
script.site_packages_path.joinpath("base-0.1.0.dist-info/WHEEL"), "a"
346339
) as f:

tests/functional/test_pep517.py

Lines changed: 14 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -197,16 +197,11 @@ def test_validate_missing_pep517_backend_requirements(
197197
project_dir = make_project(
198198
tmpdir, requires=["test_backend", "simplewheel==1.0"], backend="test_backend"
199199
)
200-
result = script.pip(
201-
"install",
202-
"--no-index",
203-
"-f",
204-
data.backends,
205-
"-f",
206-
data.packages,
200+
result = script.pip_install_local(
207201
"--no-build-isolation",
208202
"--check-build-dependencies",
209203
project_dir,
204+
find_links=[data.backends, data.packages],
210205
expect_error=True,
211206
)
212207
msg = (
@@ -224,16 +219,11 @@ def test_validate_conflicting_pep517_backend_requirements(
224219
tmpdir, requires=["simplewheel==1.0"], backend="test_backend"
225220
)
226221
script.pip("install", "simplewheel==2.0", "--no-index", "-f", data.packages)
227-
result = script.pip(
228-
"install",
229-
"--no-index",
230-
"-f",
231-
data.backends,
232-
"-f",
233-
data.packages,
222+
result = script.pip_install_local(
234223
"--no-build-isolation",
235224
"--check-build-dependencies",
236225
project_dir,
226+
find_links=[data.backends, data.packages],
237227
expect_error=True,
238228
)
239229
msg = (
@@ -271,14 +261,8 @@ def test_pep517_backend_requirements_already_satisfied(
271261
tmpdir, requires=["test_backend", "simplewheel==1.0"], backend="test_backend"
272262
)
273263
project_dir.joinpath("backend_reqs.txt").write_text("simplewheel")
274-
result = script.pip(
275-
"install",
276-
"--no-index",
277-
"-f",
278-
data.backends,
279-
"-f",
280-
data.packages,
281-
project_dir,
264+
result = script.pip_install_local(
265+
project_dir, find_links=[data.backends, data.packages]
282266
)
283267
assert "Installing backend dependencies:" not in result.stdout
284268

@@ -290,13 +274,8 @@ def test_pep517_install_with_no_cache_dir(
290274
project_dir = make_project(
291275
tmpdir, requires=["test_backend"], backend="test_backend"
292276
)
293-
result = script.pip(
294-
"install",
295-
"--no-cache-dir",
296-
"--no-index",
297-
"-f",
298-
data.backends,
299-
project_dir,
277+
result = script.pip_install_local(
278+
"--no-cache-dir", project_dir, find_links=data.backends
300279
)
301280
result.assert_installed("project", editable=False)
302281

@@ -346,13 +325,8 @@ def test_no_build_system_section(
346325
) -> None:
347326
"""Check builds with setup.py, pyproject.toml, but no build-system section."""
348327
project_dir, name = make_pyproject_with_setup(tmpdir, build_system=False)
349-
result = script.pip(
350-
"install",
351-
"--no-cache-dir",
352-
"--no-index",
353-
"-f",
354-
common_wheels,
355-
project_dir,
328+
result = script.pip_install_local(
329+
"--no-cache-dir", project_dir, find_links=common_wheels
356330
)
357331
result.assert_installed(name, editable=False)
358332

@@ -362,13 +336,8 @@ def test_no_build_backend_entry(
362336
) -> None:
363337
"""Check builds with setup.py, pyproject.toml, but no build-backend entry."""
364338
project_dir, name = make_pyproject_with_setup(tmpdir, set_backend=False)
365-
result = script.pip(
366-
"install",
367-
"--no-cache-dir",
368-
"--no-index",
369-
"-f",
370-
common_wheels,
371-
project_dir,
339+
result = script.pip_install_local(
340+
"--no-cache-dir", project_dir, find_links=common_wheels
372341
)
373342
result.assert_installed(name, editable=False)
374343

@@ -378,13 +347,8 @@ def test_explicit_setuptools_backend(
378347
) -> None:
379348
"""Check builds with setup.py, pyproject.toml, and a build-backend entry."""
380349
project_dir, name = make_pyproject_with_setup(tmpdir)
381-
result = script.pip(
382-
"install",
383-
"--no-cache-dir",
384-
"--no-index",
385-
"-f",
386-
common_wheels,
387-
project_dir,
350+
result = script.pip_install_local(
351+
"--no-cache-dir", project_dir, find_links=common_wheels
388352
)
389353
result.assert_installed(name, editable=False)
390354

tests/functional/test_show.py

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ def test_show_with_files_from_wheel(script: PipTestEnvironment, data: TestData)
5252
"""
5353
Test that a wheel's files can be listed.
5454
"""
55-
wheel_file = data.packages.joinpath("simple.dist-0.1-py2.py3-none-any.whl")
56-
script.pip("install", "--no-index", wheel_file)
55+
script.pip_install_local(data.packages / "simple.dist-0.1-py2.py3-none-any.whl")
5756
result = script.pip("show", "-f", "simple.dist")
5857
lines = result.stdout.splitlines()
5958
assert "Name: simple.dist" in lines
@@ -181,8 +180,7 @@ def test_show_verbose_installer(script: PipTestEnvironment, data: TestData) -> N
181180
"""
182181
Test that the installer is shown (this currently needs a wheel install)
183182
"""
184-
wheel_file = data.packages.joinpath("simple.dist-0.1-py2.py3-none-any.whl")
185-
script.pip("install", "--no-index", wheel_file)
183+
script.pip_install_local(data.packages / "simple.dist-0.1-py2.py3-none-any.whl")
186184
result = script.pip("show", "--verbose", "simple.dist")
187185
lines = result.stdout.splitlines()
188186
assert "Name: simple.dist" in lines
@@ -260,20 +258,18 @@ def test_pip_show_is_short(script: PipTestEnvironment) -> None:
260258
assert len(lines) <= 11
261259

262260

263-
def test_pip_show_divider(script: PipTestEnvironment, data: TestData) -> None:
261+
def test_pip_show_divider(script: PipTestEnvironment) -> None:
264262
"""
265263
Expect a divider between packages
266264
"""
267-
script.pip("install", "pip-test-package", "--no-index", "-f", data.packages)
265+
script.pip_install_local("pip-test-package")
268266
result = script.pip("show", "pip", "pip-test-package")
269267
lines = result.stdout.splitlines()
270268
assert "---" in lines
271269

272270

273-
def test_package_name_is_canonicalized(
274-
script: PipTestEnvironment, data: TestData
275-
) -> None:
276-
script.pip("install", "pip-test-package", "--no-index", "-f", data.packages)
271+
def test_package_name_is_canonicalized(script: PipTestEnvironment) -> None:
272+
script.pip_install_local("pip-test-package")
277273

278274
dash_show_result = script.pip("show", "pip-test-package")
279275
underscore_upper_show_result = script.pip("show", "pip-test_Package")
@@ -288,8 +284,7 @@ def test_show_required_by_packages_basic(
288284
"""
289285
Test that installed packages that depend on this package are shown
290286
"""
291-
editable_path = os.path.join(data.src, "requires_simple")
292-
script.pip("install", "--no-index", "-f", data.find_links, editable_path)
287+
script.pip_install_local(data.src / "requires_simple")
293288

294289
result = script.pip("show", "simple")
295290
lines = result.stdout.splitlines()
@@ -308,8 +303,7 @@ def test_show_required_by_packages_capitalized(
308303
Test that the installed packages which depend on a package are shown
309304
where the package has a capital letter
310305
"""
311-
editable_path = os.path.join(data.src, "requires_capitalized")
312-
script.pip("install", "--no-index", "-f", data.find_links, editable_path)
306+
script.pip_install_local(data.src / "requires_capitalized")
313307

314308
result = script.pip("show", "simple")
315309
lines = result.stdout.splitlines()
@@ -329,10 +323,8 @@ def test_show_required_by_packages_requiring_capitalized(
329323
where the package has a name with a mix of
330324
lower and upper case letters
331325
"""
332-
required_package_path = os.path.join(data.src, "requires_capitalized")
333-
script.pip("install", "--no-index", "-f", data.find_links, required_package_path)
334-
editable_path = os.path.join(data.src, "requires_requires_capitalized")
335-
script.pip("install", "--no-index", "-f", data.find_links, editable_path)
326+
script.pip_install_local(data.src / "requires_capitalized")
327+
script.pip_install_local(data.src / "requires_requires_capitalized")
336328

337329
result = script.pip("show", "Requires_Capitalized")
338330
lines = result.stdout.splitlines()
@@ -432,8 +424,7 @@ def test_show_license_expression(script: PipTestEnvironment, data: TestData) ->
432424
"""
433425
Show License-Expression if present in metadata >= 2.4.
434426
"""
435-
wheel_file = data.packages.joinpath("license.dist-0.1-py2.py3-none-any.whl")
436-
script.pip("install", "--no-index", wheel_file)
427+
script.pip_install_local(data.packages / "license.dist-0.1-py2.py3-none-any.whl")
437428
result = script.pip("show", "license.dist")
438429
lines = result.stdout.splitlines()
439430
assert "License-Expression: MIT AND MIT-0" in lines
@@ -446,8 +437,7 @@ def test_show_license_for_metadata_24(
446437
"""
447438
Show License if License-Expression is not there for metadata >= 2.4.
448439
"""
449-
wheel_file = data.packages.joinpath("license.dist-0.2-py2.py3-none-any.whl")
450-
script.pip("install", "--no-index", wheel_file)
440+
script.pip_install_local(data.packages / "license.dist-0.2-py2.py3-none-any.whl")
451441
result = script.pip("show", "license.dist")
452442
lines = result.stdout.splitlines()
453443
assert "License-Expression: " not in lines

0 commit comments

Comments
 (0)