File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -344,11 +344,11 @@ def setup_py(self):
344
344
assert self .source_dir , "No source dir for %s" % self
345
345
try :
346
346
import setuptools # noqa
347
- except ImportError as e :
347
+ except ImportError :
348
348
if get_installed_version ('setuptools' ) is None :
349
349
add_msg = "Please install setuptools."
350
350
else :
351
- add_msg = traceback .format_exc (e )
351
+ add_msg = traceback .format_exc ()
352
352
# Setuptools is not available
353
353
raise InstallationError (
354
354
"Could not import setuptools which is required to "
Original file line number Diff line number Diff line change @@ -30,6 +30,32 @@ def test_without_setuptools(script, data):
30
30
"source distribution."
31
31
in result .stderr
32
32
)
33
+ assert "Please install setuptools" in result .stderr
34
+
35
+
36
+ def test_with_setuptools_and_import_error (script , data ):
37
+ # Make sure we get an ImportError while importing setuptools
38
+ setuptools_init_path = script .site_packages_path .join (
39
+ "setuptools" , "__init__.py" )
40
+ with open (setuptools_init_path , 'a' ) as f :
41
+ f .write ('\n raise ImportError("toto")' )
42
+
43
+ result = script .run (
44
+ "python" , "-c" ,
45
+ "import pip; pip.main(["
46
+ "'install', "
47
+ "'INITools==0.2', "
48
+ "'-f', '%s', "
49
+ "'--no-binary=:all:'])" % data .packages ,
50
+ expect_error = True ,
51
+ )
52
+ assert (
53
+ "Could not import setuptools which is required to install from a "
54
+ "source distribution."
55
+ in result .stderr
56
+ )
57
+ assert "Traceback " in result .stderr
58
+ assert "ImportError: toto" in result .stderr
33
59
34
60
35
61
def test_pip_second_command_line_interface_works (script , data ):
You can’t perform that action at this time.
0 commit comments