提交 6ed502cb 编写于 作者: P Paul Nasrat

Merge pull request #587 from qwcode/issue_501

#501 error out if no files are found to uninstall
......@@ -1457,6 +1457,8 @@ class UninstallPathSet(object):
def remove(self, auto_confirm=False):
"""Remove paths in ``self.paths`` with confirmation (unless
``auto_confirm`` is True)."""
if not self.paths:
raise InstallationError("Can't uninstall '%s'. No files were found to uninstall." % self.dist.project_name)
if not self._can_uninstall():
return
logger.notify('Uninstalling %s:' % self.dist.project_name)
......
......@@ -2,6 +2,8 @@ import textwrap
import sys
from os.path import join, abspath
from tempfile import mkdtemp
from mock import Mock
from nose.tools import assert_raises
from tests.test_pip import here, reset_env, run_pip, assert_all_changes, write_file, pyversion
from tests.local_repos import local_repo, local_checkout
......@@ -155,3 +157,14 @@ def test_uninstall_as_egg():
result2 = run_pip('uninstall', 'FSPkg', '-y', expect_error=True)
assert_all_changes(result, result2, [env.venv/'build', 'cache'])
def test_uninstallpathset_no_paths():
"""
Test UninstallPathSet raises installation error when there are no paths (uses mocking)
"""
from pip.req import UninstallPathSet
from pip.exceptions import InstallationError
mock_dist = Mock(project_name='pkg')
uninstall_set = UninstallPathSet(mock_dist)
assert_raises(InstallationError, uninstall_set.remove)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册