Skip to content

Commit

Permalink
Add regression test for GH-1647 (#1687)
Browse files Browse the repository at this point in the history
For Windows support, this includes workarounds for
python/cpython#85815.
  • Loading branch information
gschaffner authored Nov 3, 2022
1 parent e0567a8 commit f90fcf3
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
import platform
import subprocess
import sys
from contextlib import contextmanager
Expand Down Expand Up @@ -423,3 +424,13 @@ def fake_dists(tmpdir, make_package, make_wheel):
for pkg in pkgs:
make_wheel(pkg, dists_path)
return dists_path


@pytest.fixture
def venv(tmp_path):
"""Create a temporary venv and get the path of its directory of executables."""
subprocess.run(
[sys.executable, "-m", "venv", os.fspath(tmp_path)],
check=True,
)
return tmp_path / ("Scripts" if platform.system() == "Windows" else "bin")
44 changes: 44 additions & 0 deletions tests/test_cli_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,50 @@ def test_editable_package_vcs(runner):
assert "click" in out.stderr # dependency of pip-tools


@pytest.mark.network
def test_compile_cached_vcs_package(runner, venv):
"""
Test pip-compile doesn't write local paths for cached wheels of VCS packages.
Regression test for issue GH-1647.
"""
vcs_package = (
"typing-extensions @ git+https://github.com/python/typing_extensions@"
"9c0759a260fe126210a1e2026720000a3c40a919"
)
vcs_wheel_prefix = "typing_extensions-4.3.0-py3"

# Install and cache VCS package.
subprocess.run(
[os.fspath(venv / "python"), "-m" "pip", "install", vcs_package],
check=True,
)
assert (
vcs_wheel_prefix
in subprocess.run(
[
sys.executable,
"-m" "pip",
"cache",
"list",
"--format=abspath",
vcs_wheel_prefix,
],
check=True,
capture_output=True,
text=True,
).stdout
)

with open("requirements.in", "w") as req_in:
req_in.write(vcs_package)

out = runner.invoke(cli, ["--no-header", "--no-emit-options", "--no-annotate"])

assert out.exit_code == 0, out
assert vcs_package == out.stderr.strip()


@legacy_resolver_only
def test_locally_available_editable_package_is_not_archived_in_cache_dir(
pip_conf, tmpdir, runner
Expand Down

0 comments on commit f90fcf3

Please sign in to comment.