Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add regression test for GH-1647 #1687

Merged
merged 2 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this written to the project root?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. I just followed the pattern used already for the other tests.

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