summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPradyun Gedam <pradyunsg@gmail.com>2018-12-06 08:56:40 +0530
committerGitHub <noreply@github.com>2018-12-06 08:56:40 +0530
commit3a8e21ddcf0e9abbee9ae02cc787b6e06e1d5d62 (patch)
treef0e06fb0d6e2d5dd68811dd0a8a4bbf5d46c3c35
parent36266b44b305ebab63708cb103b78dd626abe85f (diff)
parentde7fdbb7a52ea7571a443d7e9d435fb6b39349ce (diff)
downloadpip-3a8e21ddcf0e9abbee9ae02cc787b6e06e1d5d62.tar.gz
Merge pull request #6058 from uranusjr/link-package-versions-cleanup-tests
Link package versions cleanup tests
-rw-r--r--tests/unit/test_finder.py71
1 files changed, 42 insertions, 29 deletions
diff --git a/tests/unit/test_finder.py b/tests/unit/test_finder.py
index 05ebed3b5..9f82a18a8 100644
--- a/tests/unit/test_finder.py
+++ b/tests/unit/test_finder.py
@@ -11,7 +11,9 @@ from pip._internal.download import PipSession
from pip._internal.exceptions import (
BestVersionAlreadyInstalled, DistributionNotFound,
)
-from pip._internal.index import InstallationCandidate, Link, PackageFinder
+from pip._internal.index import (
+ InstallationCandidate, Link, PackageFinder, Search,
+)
from pip._internal.req.constructors import install_req_from_line
@@ -502,7 +504,7 @@ def test_finder_installs_pre_releases_with_version_spec():
assert link.url == "https://foo/bar-2.0b1.tar.gz"
-class test_link_package_versions(object):
+class TestLinkPackageVersions(object):
# patch this for travis which has distribute in its base env for now
@patch(
@@ -511,41 +513,52 @@ class test_link_package_versions(object):
)
def setup(self):
self.version = '1.0'
- self.parsed_version = parse_version(self.version)
self.search_name = 'pytest'
+ self.canonical_name = 'pytest'
self.finder = PackageFinder(
[],
[],
session=PipSession(),
)
- def test_link_package_versions_match_wheel(self):
+ @pytest.mark.parametrize(
+ 'url',
+ [
+ 'http:/yo/pytest-1.0.tar.gz',
+ 'http:/yo/pytest-1.0-py2.py3-none-any.whl',
+ ],
+ )
+ def test_link_package_versions_match(self, url):
"""Test that 'pytest' archives match for 'pytest'"""
-
- # TODO: Uncomment these, when #1217 is fixed
- # link = Link('http:/yo/pytest-1.0.tar.gz')
- # result = self.finder._link_package_versions(link, self.search_name)
- # assert result == [(self.parsed_version, link, self.version)], result
-
- link = Link('http:/yo/pytest-1.0-py2.py3-none-any.whl')
- result = self.finder._link_package_versions(link, self.search_name)
- assert result == [(self.parsed_version, link, self.version)], result
-
- def test_link_package_versions_substring_fails(self):
- """Test that 'pytest<something> archives won't match for 'pytest'"""
-
- # TODO: Uncomment these, when #1217 is fixed
- # link = Link('http:/yo/pytest-xdist-1.0.tar.gz')
- # result = self.finder._link_package_versions(link, self.search_name)
- # assert result == [], result
-
- # link = Link('http:/yo/pytest2-1.0.tar.gz')
- # result = self.finder._link_package_versions(link, self.search_name)
- # assert result == [], result
-
- link = Link('http:/yo/pytest_xdist-1.0-py2.py3-none-any.whl')
- result = self.finder._link_package_versions(link, self.search_name)
- assert result == [], result
+ link = Link(url)
+ search = Search(
+ supplied=self.search_name,
+ canonical=self.canonical_name,
+ formats=['source', 'binary'],
+ )
+ result = self.finder._link_package_versions(link, search)
+ expected = InstallationCandidate(self.search_name, self.version, link)
+ assert result == expected, result
+
+ @pytest.mark.parametrize(
+ 'url',
+ [
+ # TODO: Uncomment this test case when #1217 is fixed.
+ # 'http:/yo/pytest-xdist-1.0.tar.gz',
+ 'http:/yo/pytest2-1.0.tar.gz',
+ 'http:/yo/pytest_xdist-1.0-py2.py3-none-any.whl',
+ ],
+ )
+ def est_link_package_versions_substring_fails(self, url):
+ """Test that 'pytest<something> archives won't match for 'pytest'."""
+ link = Link(url)
+ search = Search(
+ supplied=self.search_name,
+ canonical=self.canonical_name,
+ formats=['source', 'binary'],
+ )
+ result = self.finder._link_package_versions(link, search)
+ assert result is None, result
def test_get_index_urls_locations():