def test_env_finds_fallback_executables_for_generic_env(tmp_dir, manager): venv_path = Path(tmp_dir) / "Virtual Env" child_venv_path = Path(tmp_dir) / "Child Virtual Env" manager.build_venv(str(venv_path), with_pip=True) parent_venv = VirtualEnv(venv_path) manager.build_venv(str(child_venv_path), executable=parent_venv.python, with_pip=True) venv = GenericEnv(parent_venv.path, child_env=VirtualEnv(child_venv_path)) default_executable = "python" + (".exe" if WINDOWS else "") major_executable = "python{}{}".format(sys.version_info[0], ".exe" if WINDOWS else "") minor_executable = "python{}.{}{}".format(sys.version_info[0], sys.version_info[1], ".exe" if WINDOWS else "") expected_executable = minor_executable if (venv._bin_dir.joinpath(expected_executable).exists() and venv._bin_dir.joinpath(major_executable).exists()): venv._bin_dir.joinpath(expected_executable).unlink() expected_executable = major_executable if (venv._bin_dir.joinpath(expected_executable).exists() and venv._bin_dir.joinpath(default_executable).exists()): venv._bin_dir.joinpath(expected_executable).unlink() expected_executable = default_executable default_pip_executable = "pip" + (".exe" if WINDOWS else "") major_pip_executable = "pip{}{}".format(sys.version_info[0], ".exe" if WINDOWS else "") minor_pip_executable = "pip{}.{}{}".format(sys.version_info[0], sys.version_info[1], ".exe" if WINDOWS else "") expected_pip_executable = minor_pip_executable if (venv._bin_dir.joinpath(expected_pip_executable).exists() and venv._bin_dir.joinpath(major_pip_executable).exists()): venv._bin_dir.joinpath(expected_pip_executable).unlink() expected_pip_executable = major_pip_executable if (venv._bin_dir.joinpath(expected_pip_executable).exists() and venv._bin_dir.joinpath(default_pip_executable).exists()): venv._bin_dir.joinpath(expected_pip_executable).unlink() expected_pip_executable = default_pip_executable if not venv._bin_dir.joinpath(expected_executable).exists(): expected_executable = default_executable if not venv._bin_dir.joinpath(expected_pip_executable).exists(): expected_pip_executable = default_pip_executable venv = GenericEnv(parent_venv.path, child_env=VirtualEnv(child_venv_path)) assert Path(venv.python).name == expected_executable assert Path(venv.pip).name == expected_pip_executable
def test_env_finds_the_correct_executables_for_generic_env( tmp_dir: str, manager: EnvManager ): venv_path = Path(tmp_dir) / "Virtual Env" child_venv_path = Path(tmp_dir) / "Child Virtual Env" manager.build_venv(str(venv_path), with_pip=True) parent_venv = VirtualEnv(venv_path) manager.build_venv( str(child_venv_path), executable=parent_venv.python, with_pip=True ) venv = GenericEnv(parent_venv.path, child_env=VirtualEnv(child_venv_path)) expected_executable = ( f"python{sys.version_info[0]}.{sys.version_info[1]}{'.exe' if WINDOWS else ''}" ) expected_pip_executable = ( f"pip{sys.version_info[0]}.{sys.version_info[1]}{'.exe' if WINDOWS else ''}" ) if WINDOWS: expected_executable = "python.exe" expected_pip_executable = "pip.exe" assert Path(venv.python).name == expected_executable assert Path(venv.pip).name == expected_pip_executable
def test_env_finds_the_correct_executables_for_generic_env(tmp_dir, manager): venv_path = Path(tmp_dir) / "Virtual Env" child_venv_path = Path(tmp_dir) / "Child Virtual Env" manager.build_venv(str(venv_path)) parent_venv = VirtualEnv(venv_path) manager.build_venv(str(child_venv_path), executable=parent_venv.python) venv = GenericEnv(parent_venv.path, child_env=VirtualEnv(child_venv_path)) expected_executable = "python{}.{}{}".format(sys.version_info[0], sys.version_info[1], ".exe" if WINDOWS else "") expected_pip_executable = "pip{}.{}{}".format(sys.version_info[0], sys.version_info[1], ".exe" if WINDOWS else "") if WINDOWS: expected_executable = "python.exe" expected_pip_executable = "pip.exe" assert Path(venv.python).name == expected_executable assert Path(venv.pip).name == expected_pip_executable