mirror of https://github.com/pypa/pip
More test cases
This commit is contained in:
parent
5d0a5761be
commit
033a47cbf2
|
@ -816,7 +816,7 @@ class PackageFinder(object):
|
|||
|
||||
if not version:
|
||||
version = _egg_info_matches(egg_info, search.canonical)
|
||||
if version is None:
|
||||
if not version:
|
||||
self._log_skipped_link(
|
||||
link, 'Missing project version for %s' % search.supplied)
|
||||
return
|
||||
|
@ -882,7 +882,10 @@ def _egg_info_matches(egg_info, canonical_name):
|
|||
version_start = _find_name_version_sep(egg_info, canonical_name) + 1
|
||||
except ValueError:
|
||||
return None
|
||||
return egg_info[version_start:]
|
||||
version = egg_info[version_start:]
|
||||
if not version:
|
||||
return None
|
||||
return version
|
||||
|
||||
|
||||
def _determine_base_url(document, page_url):
|
||||
|
|
|
@ -189,6 +189,10 @@ def test_get_formatted_locations_basic_auth():
|
|||
# The package name must not ends with a dash (PEP 508), so the first
|
||||
# dash would be the separator, not the second.
|
||||
("zope.interface--4.5.0", "zope-interface", 14),
|
||||
("zope.interface--", "zope-interface", 14),
|
||||
|
||||
# The version part is missing, but the split function does not care.
|
||||
("zope.interface-", "zope-interface", 14),
|
||||
],
|
||||
)
|
||||
def test_find_name_version_sep(egg_info, canonical_name, expected):
|
||||
|
@ -196,6 +200,23 @@ def test_find_name_version_sep(egg_info, canonical_name, expected):
|
|||
assert index == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("egg_info", "canonical_name"),
|
||||
[
|
||||
# A dash must follow the package name.
|
||||
("zope.interface4.5.0", "zope-interface"),
|
||||
("zope.interface.4.5.0", "zope-interface"),
|
||||
("zope.interface.-4.5.0", "zope-interface"),
|
||||
("zope.interface", "zope-interface"),
|
||||
],
|
||||
)
|
||||
def test_find_name_version_sep_failure(egg_info, canonical_name):
|
||||
with pytest.raises(ValueError) as ctx:
|
||||
_find_name_version_sep(egg_info, canonical_name)
|
||||
message = "{} does not match {}".format(egg_info, canonical_name)
|
||||
assert str(ctx.value) == message
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("egg_info", "canonical_name", "expected"),
|
||||
[
|
||||
|
@ -212,6 +233,8 @@ def test_find_name_version_sep(egg_info, canonical_name, expected):
|
|||
# package name.
|
||||
("foo-2-2", "foo", "2-2"),
|
||||
("foo-2-2", "foo-2", "2"),
|
||||
("zope.interface--4.5.0", "zope-interface", "-4.5.0"),
|
||||
("zope.interface--", "zope-interface", "-"),
|
||||
|
||||
# Should be able to detect collapsed characters in the egg info.
|
||||
("foo--bar-1.0", "foo-bar", "1.0"),
|
||||
|
@ -220,6 +243,11 @@ def test_find_name_version_sep(egg_info, canonical_name, expected):
|
|||
# Invalid.
|
||||
("the-package-name-8.19", "does-not-match", None),
|
||||
("zope.interface.-4.5.0", "zope.interface", None),
|
||||
("zope.interface-", "zope-interface", None),
|
||||
("zope.interface4.5.0", "zope-interface", None),
|
||||
("zope.interface.4.5.0", "zope-interface", None),
|
||||
("zope.interface.-4.5.0", "zope-interface", None),
|
||||
("zope.interface", "zope-interface", None),
|
||||
],
|
||||
)
|
||||
def test_egg_info_matches(egg_info, canonical_name, expected):
|
||||
|
|
Loading…
Reference in New Issue