summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVincent Fazio <vfazio@gmail.com>2022-11-12 15:36:44 -0600
committerGitHub <noreply@github.com>2022-11-12 13:36:44 -0800
commitcf36e4f485fe06c9b52dd657c02b84867e4b8bce (patch)
tree5d16e19d2b04d57b3a7799e29a13a9ca62af0afd /tests
parentb7178cdbfe1e6b59734137c142ae260673698a0e (diff)
downloadvirtualenv-cf36e4f485fe06c9b52dd657c02b84867e4b8bce.tar.gz
Set 'home' to parent directory of system_executable (#2441)
close https://github.com/pypa/virtualenv/issues/2440
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/create/test_creator.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/unit/create/test_creator.py b/tests/unit/create/test_creator.py
index d3adb2a..db323cd 100644
--- a/tests/unit/create/test_creator.py
+++ b/tests/unit/create/test_creator.py
@@ -318,6 +318,28 @@ def test_prompt_set(tmp_path, creator, prompt):
assert cfg["prompt"] == actual_prompt
+@pytest.mark.parametrize("creator", CURRENT_CREATORS)
+def test_home_path_is_exe_parent(tmp_path, creator):
+ cmd = [str(tmp_path), "--seeder", "app-data", "--without-pip", "--creator", creator]
+
+ result = cli_run(cmd)
+ cfg = PyEnvCfg.from_file(result.creator.pyenv_cfg.path)
+
+ # Cannot assume "home" path is a specific value as path resolution may change
+ # between versions (symlinks, framework paths, etc) but we can check that a
+ # python executable is present from the configured path per PEP 405
+ if sys.platform == "win32":
+ exes = ("python.exe",)
+ else:
+ exes = (
+ "python",
+ f"python{sys.version_info.major}",
+ f"python{sys.version_info.major}.{sys.version_info.minor}",
+ )
+
+ assert any(os.path.exists(os.path.join(cfg["home"], exe)) for exe in exes)
+
+
@pytest.mark.slow()
@pytest.mark.usefixtures("current_fastest")
def test_cross_major(cross_python, coverage_env, tmp_path, session_app_data):