@@ -39,3 +39,33 @@ def test_custom_interpreter(
39
39
if sys .version_info >= (3 , 12 ):
40
40
expected -= {"setuptools" , "wheel" }
41
41
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