Skip to content

Commit bfa96b5

Browse files
shifquwebknjaz
andcommitted
tests: provide minimal_wheels_path as a fixture
Tests using MINIMAL_WHEELS_PATH have also been updated to use this new session-scoped fixture Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
1 parent 10a4b44 commit bfa96b5

File tree

2 files changed

+46
-11
lines changed

2 files changed

+46
-11
lines changed

tests/conftest.py

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
import os
55
import platform
6+
import shutil
67
import subprocess
78
import sys
89
from contextlib import contextmanager
@@ -266,26 +267,26 @@ def _make_pip_conf(content):
266267

267268

268269
@pytest.fixture
269-
def pip_conf(make_pip_conf):
270+
def pip_conf(make_pip_conf, minimal_wheels_path):
270271
return make_pip_conf(
271272
dedent(
272273
f"""\
273274
[global]
274275
no-index = true
275-
find-links = {MINIMAL_WHEELS_PATH}
276+
find-links = {minimal_wheels_path.as_posix()}
276277
"""
277278
)
278279
)
279280

280281

281282
@pytest.fixture
282-
def pip_with_index_conf(make_pip_conf):
283+
def pip_with_index_conf(make_pip_conf, minimal_wheels_path):
283284
return make_pip_conf(
284285
dedent(
285286
f"""\
286287
[global]
287288
index-url = http://example.com
288-
find-links = {MINIMAL_WHEELS_PATH}
289+
find-links = {minimal_wheels_path.as_posix()}
289290
"""
290291
)
291292
)
@@ -524,3 +525,32 @@ def _maker(
524525
return cast(Path, config_file.relative_to(tmpdir_cwd))
525526

526527
return _maker
528+
529+
530+
@pytest.fixture(scope="session")
531+
def setuptools_wheel_path(tmp_path_factory):
532+
"""
533+
Ensure setuptools is downloaded and return the path to the download directory.
534+
"""
535+
tmp_wheels_path = tmp_path_factory.mktemp("tmp_wheels")
536+
subprocess.check_call(
537+
[
538+
sys.executable,
539+
"-Im",
540+
"pip",
541+
"download",
542+
f"--dest={tmp_wheels_path.as_posix()}",
543+
"--no-deps",
544+
"setuptools",
545+
],
546+
)
547+
return tmp_wheels_path
548+
549+
550+
@pytest.fixture(scope="session")
551+
def minimal_wheels_path(setuptools_wheel_path):
552+
"""
553+
Ensure minimal wheels and setuptools are downloaded and return the path.
554+
"""
555+
shutil.copytree(MINIMAL_WHEELS_PATH, setuptools_wheel_path, dirs_exist_ok=True)
556+
return setuptools_wheel_path

tests/test_cli_compile.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def test_command_line_overrides_pip_conf(pip_with_index_conf, runner):
165165
),
166166
)
167167
def test_command_line_setuptools_read(
168-
runner, make_package, install_requires, expected_output
168+
runner, make_package, minimal_wheels_path, install_requires, expected_output
169169
):
170170
package_dir = make_package(
171171
name="fake-setuptools-a",
@@ -177,7 +177,7 @@ def test_command_line_setuptools_read(
177177
(
178178
str(package_dir / "setup.py"),
179179
"--find-links",
180-
MINIMAL_WHEELS_PATH,
180+
minimal_wheels_path.as_posix(),
181181
"--no-build-isolation",
182182
),
183183
)
@@ -3430,7 +3430,9 @@ def test_pass_pip_cache_to_pip_args(tmpdir, runner, current_resolver):
34303430

34313431

34323432
@backtracking_resolver_only
3433-
def test_compile_recursive_extras_static(runner, tmp_path, current_resolver):
3433+
def test_compile_recursive_extras_static(
3434+
runner, tmp_path, minimal_wheels_path, current_resolver
3435+
):
34343436
(tmp_path / "pyproject.toml").write_text(
34353437
dedent(
34363438
"""
@@ -3454,7 +3456,7 @@ def test_compile_recursive_extras_static(runner, tmp_path, current_resolver):
34543456
"--extra",
34553457
"dev",
34563458
"--find-links",
3457-
os.fspath(MINIMAL_WHEELS_PATH),
3459+
minimal_wheels_path.as_posix(),
34583460
os.fspath(tmp_path / "pyproject.toml"),
34593461
"--output-file",
34603462
"-",
@@ -3474,7 +3476,9 @@ def test_compile_recursive_extras_static(runner, tmp_path, current_resolver):
34743476

34753477

34763478
@backtracking_resolver_only
3477-
def test_compile_recursive_extras_build_targets(runner, tmp_path, current_resolver):
3479+
def test_compile_recursive_extras_build_targets(
3480+
runner, tmp_path, minimal_wheels_path, current_resolver
3481+
):
34783482
(tmp_path / "pyproject.toml").write_text(
34793483
dedent(
34803484
"""
@@ -3500,7 +3504,7 @@ def test_compile_recursive_extras_build_targets(runner, tmp_path, current_resolv
35003504
"--build-deps-for",
35013505
"wheel",
35023506
"--find-links",
3503-
os.fspath(MINIMAL_WHEELS_PATH),
3507+
minimal_wheels_path.as_posix(),
35043508
os.fspath(tmp_path / "pyproject.toml"),
35053509
"--output-file",
35063510
"-",
@@ -3526,6 +3530,7 @@ def test_compile_recursive_extras_build_targets(runner, tmp_path, current_resolv
35263530
def test_compile_build_targets_setuptools_no_wheel_dep(
35273531
runner,
35283532
tmp_path,
3533+
minimal_wheels_path,
35293534
current_resolver,
35303535
):
35313536
"""Check that user requests apply to build dependencies.
@@ -3566,7 +3571,7 @@ def test_compile_build_targets_setuptools_no_wheel_dep(
35663571
"--build-deps-for",
35673572
"wheel",
35683573
"--find-links",
3569-
os.fspath(MINIMAL_WHEELS_PATH),
3574+
minimal_wheels_path.as_posix(),
35703575
os.fspath(tmp_path / "pyproject.toml"),
35713576
"--constraint",
35723577
os.fspath(tmp_path / "constraints.txt"),

0 commit comments

Comments
 (0)