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), ]
def test_on_windows(self, monkeypatch): assert virtualenv.IS_WIN mock_winreg = self.mock_virtualenv_winreg( monkeypatch, { self.key_local_machine: ( "2.4", "2.7", "3.2", "3.4", "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", "3.2": self.key_local_machine + "-3.2-path\\python.exe", "3.2-32": self.key_local_machine + "-3.2-path\\python.exe", "3.4": self.key_local_machine + "-3.4-path\\python.exe", "3.4-32": self.key_local_machine + "-3.4-path\\python.exe", "3.5": self.key_local_machine_64 + "-3.5-path\\python.exe", "3.5-64": self.key_local_machine_64 + "-3.5-path\\python.exe", "3.6": self.key_local_machine + "-3.6-32-path\\python.exe", "3.6-32": self.key_local_machine + "-3.6-32-path\\python.exe", "3.7": self.key_current_user_64 + "-3.7-path\\python.exe", "3.7-32": self.key_local_machine + "-3.7-32-path\\python.exe", "3.7-64": self.key_current_user_64 + "-3.7-path\\python.exe", "3.8": self.key_local_machine_64 + "-3.8-path\\python.exe", "3.8-32": self.key_current_user + "-3.8-32-path\\python.exe", "3.8-64": self.key_local_machine_64 + "-3.8-path\\python.exe", } 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.QueryValue(self.key_local_machine, "2.4\\InstallPath"), call.EnumKey(self.key_local_machine, 1), call.QueryValue(self.key_local_machine, "2.7\\InstallPath"), call.EnumKey(self.key_local_machine, 2), call.QueryValue(self.key_local_machine, "3.2\\InstallPath"), call.EnumKey(self.key_local_machine, 3), call.QueryValue(self.key_local_machine, "3.4\\InstallPath"), call.EnumKey(self.key_local_machine, 4), call.QueryValue(self.key_local_machine, "3.6-32\\InstallPath"), call.EnumKey(self.key_local_machine, 5), call.QueryValue(self.key_local_machine, "3.7-32\\InstallPath"), call.EnumKey(self.key_local_machine, 6), 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.QueryValue(self.key_current_user, "2.5\\InstallPath"), call.EnumKey(self.key_current_user, 1), call.QueryValue(self.key_current_user, "2.7\\InstallPath"), call.EnumKey(self.key_current_user, 2), call.QueryValue(self.key_current_user, "3.8-32\\InstallPath"), call.EnumKey(self.key_current_user, 3), 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.QueryValue(self.key_local_machine_64, "2.6\\InstallPath"), call.EnumKey(self.key_local_machine_64, 1), call.QueryValue(self.key_local_machine_64, "3.5\\InstallPath"), call.EnumKey(self.key_local_machine_64, 2), call.QueryValue(self.key_local_machine_64, "3.7\\InstallPath"), call.EnumKey(self.key_local_machine_64, 3), call.QueryValue(self.key_local_machine_64, "3.8\\InstallPath"), call.EnumKey(self.key_local_machine_64, 4), 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.QueryValue(self.key_current_user_64, "3.7\\InstallPath"), call.EnumKey(self.key_current_user_64, 1), call.CloseKey(self.key_current_user_64), ]