summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Fernandez <xavier.fernandez@polyconseil.fr>2015-10-23 23:49:38 +0200
committerXavier Fernandez <xavier.fernandez@polyconseil.fr>2015-10-24 00:46:44 +0200
commit0cc9d733bfc42bcaef58bae621d8d674b98cb705 (patch)
tree70a32676d14f1aeade1af6c7b1a134a84bd97bf4
parentf23cbb707ff9436c98ed57714a2605ccd04a4277 (diff)
downloadpip-0cc9d733bfc42bcaef58bae621d8d674b98cb705.tar.gz
Fix traceback.format_exc call
format_exc takes only one argument, limit which should be an integer. python 2 seems more lenient than python 3 on that point. mistake introduced in commit 3148b967a
-rw-r--r--pip/req/req_install.py4
-rw-r--r--tests/functional/test_install.py26
2 files changed, 28 insertions, 2 deletions
diff --git a/pip/req/req_install.py b/pip/req/req_install.py
index 83b817a44..4ed58f29c 100644
--- a/pip/req/req_install.py
+++ b/pip/req/req_install.py
@@ -344,11 +344,11 @@ class InstallRequirement(object):
assert self.source_dir, "No source dir for %s" % self
try:
import setuptools # noqa
- except ImportError as e:
+ except ImportError:
if get_installed_version('setuptools') is None:
add_msg = "Please install setuptools."
else:
- add_msg = traceback.format_exc(e)
+ add_msg = traceback.format_exc()
# Setuptools is not available
raise InstallationError(
"Could not import setuptools which is required to "
diff --git a/tests/functional/test_install.py b/tests/functional/test_install.py
index 47ca38cd4..c54fe7e3c 100644
--- a/tests/functional/test_install.py
+++ b/tests/functional/test_install.py
@@ -30,6 +30,32 @@ def test_without_setuptools(script, data):
"source distribution."
in result.stderr
)
+ assert "Please install setuptools" in result.stderr
+
+
+def test_with_setuptools_and_import_error(script, data):
+ # Make sure we get an ImportError while importing setuptools
+ setuptools_init_path = script.site_packages_path.join(
+ "setuptools", "__init__.py")
+ with open(setuptools_init_path, 'a') as f:
+ f.write('\nraise ImportError("toto")')
+
+ result = script.run(
+ "python", "-c",
+ "import pip; pip.main(["
+ "'install', "
+ "'INITools==0.2', "
+ "'-f', '%s', "
+ "'--no-binary=:all:'])" % data.packages,
+ expect_error=True,
+ )
+ assert (
+ "Could not import setuptools which is required to install from a "
+ "source distribution."
+ in result.stderr
+ )
+ assert "Traceback " in result.stderr
+ assert "ImportError: toto" in result.stderr
def test_pip_second_command_line_interface_works(script, data):