Skip to content

Commit 8c54c10

Browse files
committed
add testcases for --python with --local-only
1 parent a73123a commit 8c54c10

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/test_non_host.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,33 @@ def test_custom_interpreter(
3939
if sys.version_info >= (3, 12):
4040
expected -= {"setuptools", "wheel"}
4141
assert found == expected, out
42+
43+
44+
def test_custom_interpreter_with_local_only(
45+
tmp_path: Path,
46+
monkeypatch: pytest.MonkeyPatch,
47+
capfd: pytest.CaptureFixture[str],
48+
) -> None:
49+
venv_path = str(tmp_path / "venv")
50+
51+
result = virtualenv.cli_run([venv_path, "--system-site-packages", "--activators", ""])
52+
53+
cmd = [sys.executable]
54+
monkeypatch.chdir(tmp_path)
55+
cmd += [f"--python={result.creator.exe}"]
56+
cmd += ["--local-only"]
57+
monkeypatch.setattr(sys, "prefix", venv_path)
58+
monkeypatch.setattr(sys, "argv", cmd)
59+
main()
60+
out, _ = capfd.readouterr()
61+
found = {i.split("==")[0] for i in out.splitlines()}
62+
implementation = python_implementation()
63+
if implementation == "CPython":
64+
expected = {"pip", "setuptools", "wheel"}
65+
elif implementation == "PyPy": # pragma: no cover
66+
expected = {"cffi", "greenlet", "pip", "readline", "setuptools", "wheel"} # pragma: no cover
67+
else:
68+
raise ValueError(implementation) # pragma: no cover
69+
if sys.version_info >= (3, 12):
70+
expected -= {"setuptools", "wheel"} # pragma: no cover
71+
assert found == expected, out

0 commit comments

Comments
 (0)