def test_download_pip_installer(self): mgr = PipManager('/usr/bin', pip_installed=False) with tempfile.NamedTemporaryFile() as temp_file: mgr.pip_installer_fname = temp_file.name 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_download_pip_installer(mocker, tmp_path): tmp_file = str(tmp_path / "hello.txt") mgr = PipManager(BIN_PATH, pip_installed=False) mgr.pip_installer_fname = tmp_file urlopen = mocker.patch("fades.pipmanager.request.urlopen", return_value=io.BytesIO(b"hola")) mgr._download_pip_installer() assert os.path.exists(mgr.pip_installer_fname) urlopen.assert_called_once_with(pipmanager.PIP_INSTALLER)
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_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)