@@ -69,7 +69,7 @@ def check_output(cmd: list[str], *args: Any, **kwargs: Any) -> str:
69
69
return f"/usr/bin/{ basename } "
70
70
71
71
if "print(sys.base_prefix)" in python_cmd :
72
- return "/usr"
72
+ return sys . base_prefix
73
73
74
74
assert "import sys; print(sys.prefix)" in python_cmd
75
75
return "/prefix"
@@ -141,7 +141,7 @@ def test_activate_in_project_venv_no_explicit_config(
141
141
env = manager .activate ("python3.7" )
142
142
143
143
assert env .path == tmp_path / "poetry-fixture-simple" / ".venv"
144
- assert env .base == Path ("/usr" )
144
+ assert env .base == Path (sys . base_prefix )
145
145
146
146
m .assert_called_with (
147
147
tmp_path / "poetry-fixture-simple" / ".venv" ,
@@ -197,7 +197,7 @@ def test_activate_activates_non_existing_virtualenv_no_envs_file(
197
197
assert envs [venv_name ]["patch" ] == "3.7.1"
198
198
199
199
assert env .path == tmp_path / f"{ venv_name } -py3.7"
200
- assert env .base == Path ("/usr" )
200
+ assert env .base == Path (sys . base_prefix )
201
201
202
202
203
203
def test_activate_fails_when_python_cannot_be_found (
@@ -257,7 +257,7 @@ def test_activate_activates_existing_virtualenv_no_envs_file(
257
257
assert envs [venv_name ]["patch" ] == "3.7.1"
258
258
259
259
assert env .path == tmp_path / f"{ venv_name } -py3.7"
260
- assert env .base == Path ("/usr" )
260
+ assert env .base == Path (sys . base_prefix )
261
261
262
262
263
263
def test_activate_activates_same_virtualenv_with_envs_file (
@@ -297,7 +297,7 @@ def test_activate_activates_same_virtualenv_with_envs_file(
297
297
assert envs [venv_name ]["patch" ] == "3.7.1"
298
298
299
299
assert env .path == tmp_path / f"{ venv_name } -py3.7"
300
- assert env .base == Path ("/usr" )
300
+ assert env .base == Path (sys . base_prefix )
301
301
302
302
303
303
def test_activate_activates_different_virtualenv_with_envs_file (
@@ -343,7 +343,7 @@ def test_activate_activates_different_virtualenv_with_envs_file(
343
343
assert envs [venv_name ]["patch" ] == "3.6.6"
344
344
345
345
assert env .path == tmp_path / f"{ venv_name } -py3.6"
346
- assert env .base == Path ("/usr" )
346
+ assert env .base == Path (sys . base_prefix )
347
347
348
348
349
349
def test_activate_activates_recreates_for_different_patch (
@@ -395,7 +395,7 @@ def test_activate_activates_recreates_for_different_patch(
395
395
assert envs [venv_name ]["patch" ] == "3.7.1"
396
396
397
397
assert env .path == tmp_path / f"{ venv_name } -py3.7"
398
- assert env .base == Path ("/usr" )
398
+ assert env .base == Path (sys . base_prefix )
399
399
assert (tmp_path / f"{ venv_name } -py3.7" ).exists ()
400
400
401
401
@@ -443,7 +443,7 @@ def test_activate_does_not_recreate_when_switching_minor(
443
443
assert envs [venv_name ]["patch" ] == "3.6.6"
444
444
445
445
assert env .path == tmp_path / f"{ venv_name } -py3.6"
446
- assert env .base == Path ("/usr" )
446
+ assert env .base == Path (sys . base_prefix )
447
447
assert (tmp_path / f"{ venv_name } -py3.6" ).exists ()
448
448
449
449
@@ -595,7 +595,7 @@ def test_get_prefers_explicitly_activated_virtualenvs_over_env_var(
595
595
env = manager .get ()
596
596
597
597
assert env .path == tmp_path / f"{ venv_name } -py3.7"
598
- assert env .base == Path ("/usr" )
598
+ assert env .base == Path (sys . base_prefix )
599
599
600
600
601
601
def test_list (
@@ -967,12 +967,12 @@ def test_create_venv_tries_to_find_a_compatible_python_executable_using_specific
967
967
mocker .patch (
968
968
"subprocess.check_output" ,
969
969
side_effect = [
970
- "/usr" ,
970
+ sys . base_prefix ,
971
971
"/usr/bin/python3" ,
972
972
"3.5.3" ,
973
973
"/usr/bin/python3.9" ,
974
974
"3.9.0" ,
975
- "/usr" ,
975
+ sys . base_prefix ,
976
976
],
977
977
)
978
978
m = mocker .patch (
@@ -997,7 +997,7 @@ def test_create_venv_fails_if_no_compatible_python_version_could_be_found(
997
997
998
998
poetry .package .python_versions = "^4.8"
999
999
1000
- mocker .patch ("subprocess.check_output" , side_effect = ["/usr" ])
1000
+ mocker .patch ("subprocess.check_output" , side_effect = [sys . base_prefix ])
1001
1001
m = mocker .patch (
1002
1002
"poetry.utils.env.EnvManager.build_venv" , side_effect = lambda * args , ** kwargs : ""
1003
1003
)
@@ -1023,7 +1023,7 @@ def test_create_venv_does_not_try_to_find_compatible_versions_with_executable(
1023
1023
1024
1024
poetry .package .python_versions = "^4.8"
1025
1025
1026
- mocker .patch ("subprocess.check_output" , side_effect = ["/usr" , "3.8.0" ])
1026
+ mocker .patch ("subprocess.check_output" , side_effect = [sys . base_prefix , "3.8.0" ])
1027
1027
m = mocker .patch (
1028
1028
"poetry.utils.env.EnvManager.build_venv" , side_effect = lambda * args , ** kwargs : ""
1029
1029
)
@@ -1208,7 +1208,7 @@ def mock_check_output(cmd: str, *args: Any, **kwargs: Any) -> str:
1208
1208
return "3.7.1"
1209
1209
1210
1210
if GET_BASE_PREFIX in cmd :
1211
- return "/usr"
1211
+ return sys . base_prefix
1212
1212
1213
1213
return "/usr/bin/python3.5"
1214
1214
0 commit comments