Skip to content

Commit 5528d35

Browse files
committed
Add some tests of CandidateEvaluator.evaluate_link().
1 parent ad2b078 commit 5528d35

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

tests/unit/test_index.py

+29-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
from pip._internal.download import PipSession
1010
from pip._internal.index import (
11-
CandidateEvaluator, Link, PackageFinder, _check_link_requires_python,
12-
_clean_link, _determine_base_url, _egg_info_matches,
13-
_find_name_version_sep, _get_html_page,
11+
CandidateEvaluator, Link, PackageFinder, Search,
12+
_check_link_requires_python, _clean_link, _determine_base_url,
13+
_egg_info_matches, _find_name_version_sep, _get_html_page,
1414
)
1515

1616

@@ -104,6 +104,32 @@ def test_init__py_version_default(self):
104104
index = sys.version.find('.', 2)
105105
assert evaluator._py_version == sys.version[:index]
106106

107+
@pytest.mark.parametrize(
108+
'py_version_info,ignore_requires_python,expected', [
109+
((3, 6, 5), None, (True, '1.12')),
110+
# Test an incompatible Python.
111+
((3, 6, 4), None, (False, None)),
112+
# Test an incompatible Python with ignore_requires_python=True.
113+
((3, 6, 4), True, (True, '1.12')),
114+
],
115+
)
116+
def test_evaluate_link(
117+
self, py_version_info, ignore_requires_python, expected,
118+
):
119+
link = Link(
120+
'https://example.com/#egg=twine-1.12',
121+
requires_python='== 3.6.5',
122+
)
123+
search = Search(
124+
supplied='twine', canonical='twine', formats=['source'],
125+
)
126+
evaluator = CandidateEvaluator(
127+
[], py_version_info=py_version_info,
128+
ignore_requires_python=ignore_requires_python,
129+
)
130+
actual = evaluator.evaluate_link(link, search=search)
131+
assert actual == expected
132+
107133

108134
def test_sort_locations_file_expand_dir(data):
109135
"""

0 commit comments

Comments
 (0)