How to use the virtualenv.get_installed_pythons function in virtualenv

To help you get started, we’ve selected a few virtualenv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pypa / virtualenv / tests / test_zipapp.py View on Github external
def _python(v):
    return virtualenv.get_installed_pythons().get(v, "python{}".format(v))
github pypa / virtualenv / tests / test_virtualenv.py View on Github external
def test_on_non_windows(self, monkeypatch):
        assert not virtualenv.IS_WIN
        assert not hasattr(virtualenv, "winreg")
        assert virtualenv.get_installed_pythons() == {}
github pypa / virtualenv / tests / test_virtualenv.py View on Github external
"3.6-32",  # 32-bit only
                    "3.7-32",  # both 32 & 64-bit with a 64-bit user install
                ),
                self.key_current_user: ("2.5", "2.7", "3.8-32"),
                self.key_local_machine_64: (
                    "2.6",
                    "3.5",  # 64-bit only
                    "3.7",
                    "3.8",  # 64-bit with a 32-bit user install
                ),
                self.key_current_user_64: ("3.7",),
            },
        )
        monkeypatch.setattr(virtualenv, "join", "{}\\{}".format)

        installed_pythons = virtualenv.get_installed_pythons()

        assert installed_pythons == {
            "2": self.key_current_user + "-2.7-path\\python.exe",
            "2-32": self.key_current_user + "-2.7-path\\python.exe",
            "2-64": self.key_local_machine_64 + "-2.6-path\\python.exe",
            "2.4": self.key_local_machine + "-2.4-path\\python.exe",
            "2.4-32": self.key_local_machine + "-2.4-path\\python.exe",
            "2.5": self.key_current_user + "-2.5-path\\python.exe",
            "2.5-32": self.key_current_user + "-2.5-path\\python.exe",
            "2.6": self.key_local_machine_64 + "-2.6-path\\python.exe",
            "2.6-64": self.key_local_machine_64 + "-2.6-path\\python.exe",
            "2.7": self.key_current_user + "-2.7-path\\python.exe",
            "2.7-32": self.key_current_user + "-2.7-path\\python.exe",
            "3": self.key_local_machine_64 + "-3.8-path\\python.exe",
            "3-32": self.key_current_user + "-3.8-32-path\\python.exe",
            "3-64": self.key_local_machine_64 + "-3.8-path\\python.exe",
github pypa / virtualenv / tests / test_virtualenv.py View on Github external
def test_on_windows_with_no_installations(self, monkeypatch):
        assert virtualenv.IS_WIN
        mock_winreg = self.mock_virtualenv_winreg(monkeypatch, {})

        installed_pythons = virtualenv.get_installed_pythons()

        assert installed_pythons == {}
        assert mock_winreg.mock_calls == [
            call.OpenKey(mock_winreg.HKEY_LOCAL_MACHINE, "Software\\Python\\PythonCore", 0, 0x11),
            call.EnumKey(self.key_local_machine, 0),
            call.CloseKey(self.key_local_machine),
            call.OpenKey(mock_winreg.HKEY_CURRENT_USER, "Software\\Python\\PythonCore", 0, 0x11),
            call.EnumKey(self.key_current_user, 0),
            call.CloseKey(self.key_current_user),
            call.OpenKey(mock_winreg.HKEY_LOCAL_MACHINE, "Software\\Python\\PythonCore", 0, 0x12),
            call.EnumKey(self.key_local_machine_64, 0),
            call.CloseKey(self.key_local_machine_64),
            call.OpenKey(mock_winreg.HKEY_CURRENT_USER, "Software\\Python\\PythonCore", 0, 0x12),
            call.EnumKey(self.key_current_user_64, 0),
            call.CloseKey(self.key_current_user_64),
        ]