mirror of https://github.com/pypa/pip
parent
49af40e173
commit
7adacc8b18
|
@ -0,0 +1 @@
|
|||
Improve the error message for the common ``pip install ./requirements.txt`` case.
|
|
@ -1069,7 +1069,7 @@ def deduce_helpful_msg(req):
|
|||
try:
|
||||
with open(req, 'r') as fp:
|
||||
# parse first line only
|
||||
parse_requirements(fp.read()).next()
|
||||
next(parse_requirements(fp.read()))
|
||||
msg += " The argument you provided " + \
|
||||
"(%s) appears to be a" % (req) + \
|
||||
" requirements file. If that is the" + \
|
||||
|
|
|
@ -524,6 +524,18 @@ class TestInstallRequirement(object):
|
|||
assert "Invalid requirement" in err_msg
|
||||
assert "\nTraceback " in err_msg
|
||||
|
||||
def test_requirement_file(self):
|
||||
req_file_path = os.path.join(self.tempdir, 'test.txt')
|
||||
with open(req_file_path, 'w') as req_file:
|
||||
req_file.write('pip\nsetuptools')
|
||||
with pytest.raises(InstallationError) as e:
|
||||
InstallRequirement.from_line(req_file_path)
|
||||
err_msg = e.value.args[0]
|
||||
assert "Invalid requirement" in err_msg
|
||||
assert "It looks like a path. It does exist." in err_msg
|
||||
assert "appears to be a requirements file." in err_msg
|
||||
assert "If that is the case, use the '-r' flag to install" in err_msg
|
||||
|
||||
|
||||
def test_requirements_data_structure_keeps_order():
|
||||
requirements = Requirements()
|
||||
|
|
Loading…
Reference in New Issue