def test_download_pip_installer(self): mgr = PipManager(BIN_PATH, pip_installed=False) # get a tempfile and remove it, so later the installer is downloaded there tempfile = get_tempfile(self) os.remove(tempfile) mgr.pip_installer_fname = tempfile with patch('fades.pipmanager.request.urlopen') as urlopen: urlopen.return_value = io.BytesIO(b'hola') mgr._download_pip_installer() self.assertTrue(os.path.exists(mgr.pip_installer_fname)) urlopen.assert_called_once_with(pipmanager.PIP_INSTALLER)
def test_brute_force_install_pip_installer_exists(self): mgr = PipManager(BIN_PATH, pip_installed=False) python_path = os.path.join(BIN_PATH, 'python') with patch.object(helpers, 'logged_exec') as mocked_exec, \ patch.object(mgr, '_download_pip_installer') as download_installer: # get the tempfile but leave it there to be found mgr.pip_installer_fname = get_tempfile(self) mgr._brute_force_install_pip() self.assertEqual(download_installer.call_count, 0) mocked_exec.assert_called_with([python_path, mgr.pip_installer_fname, '-I']) self.assertTrue(mgr.pip_installed)
def test_brute_force_install_pip_no_installer(self): mgr = PipManager(BIN_PATH, pip_installed=False) python_path = os.path.join(BIN_PATH, 'python') with patch.object(helpers, 'logged_exec') as mocked_exec, \ patch.object(mgr, '_download_pip_installer') as download_installer: # get the tempfile and remove it so then it's not found tempfile = get_tempfile(self) os.remove(tempfile) mgr.pip_installer_fname = tempfile mgr._brute_force_install_pip() download_installer.assert_called_once_with() mocked_exec.assert_called_with([python_path, mgr.pip_installer_fname, '-I']) self.assertTrue(mgr.pip_installed)
def setUp(self): super().setUp() tempfile = get_tempfile(self) self.venvscache = cache.VEnvsCache(tempfile)
def setUp(self): super().setUp() self.tempfile = get_tempfile(self)