mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Merge pull request #3496 from edmorley/use-url-in-suggested-hashes
Correct package hash line suggestions for URL requirements
This commit is contained in:
commit
b13a2c691e
|
@ -160,13 +160,16 @@ class HashMissing(HashError):
|
|||
def body(self):
|
||||
from pip.utils.hashes import FAVORITE_HASH # Dodge circular import.
|
||||
|
||||
package_name = (self.req.req if self.req and
|
||||
# In case someone feeds something
|
||||
# downright stupid to
|
||||
# InstallRequirement's constructor:
|
||||
getattr(self.req, 'req', None)
|
||||
else 'unknown package')
|
||||
return ' %s --hash=%s:%s' % (package_name,
|
||||
package = None
|
||||
if self.req:
|
||||
# In the case of URL-based requirements, display the original URL
|
||||
# seen in the requirements file rather than the package name,
|
||||
# so the output can be directly copied into the requirements file.
|
||||
package = (self.req.original_link if self.req.original_link
|
||||
# In case someone feeds something downright stupid
|
||||
# to InstallRequirement's constructor.
|
||||
else getattr(self.req, 'req', None))
|
||||
return ' %s --hash=%s:%s' % (package or 'unknown package',
|
||||
FAVORITE_HASH,
|
||||
self.gotten_hash)
|
||||
|
||||
|
|
|
@ -93,6 +93,12 @@ class TestRequirementSet(object):
|
|||
list(process_line('https://pypi.python.org/packages/source/m/more-'
|
||||
'itertools/more-itertools-1.0.tar.gz#md5=b21850c'
|
||||
'3cfa7efbb70fd662ab5413bdd', 'file', 3))[0])
|
||||
# The error text should list this as a URL and not `peep==3.1.1`:
|
||||
reqset.add_requirement(
|
||||
list(process_line('https://pypi.python.org/packages/source/p/peep/'
|
||||
'peep-3.1.1.tar.gz',
|
||||
'file',
|
||||
4))[0])
|
||||
finder = PackageFinder([],
|
||||
['https://pypi.python.org/simple'],
|
||||
session=PipSession())
|
||||
|
@ -100,6 +106,8 @@ class TestRequirementSet(object):
|
|||
HashErrors,
|
||||
r'Hashes are required in --require-hashes mode, but they are '
|
||||
r'missing .*\n'
|
||||
r' https://pypi\.python\.org/packages/source/p/peep/peep'
|
||||
r'-3\.1\.1\.tar\.gz --hash=sha256:[0-9a-f]+\n'
|
||||
r' blessings==1.0 --hash=sha256:[0-9a-f]+\n'
|
||||
r'THESE PACKAGES DO NOT MATCH THE HASHES.*\n'
|
||||
r' tracefront==0.1 .*:\n'
|
||||
|
|
Loading…
Reference in a new issue