|
8 | 8 |
|
9 | 9 | from pip._internal.download import PipSession
|
10 | 10 | 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, |
14 | 14 | )
|
15 | 15 |
|
16 | 16 |
|
@@ -104,6 +104,32 @@ def test_init__py_version_default(self):
|
104 | 104 | index = sys.version.find('.', 2)
|
105 | 105 | assert evaluator._py_version == sys.version[:index]
|
106 | 106 |
|
| 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 | + |
107 | 133 |
|
108 | 134 | def test_sort_locations_file_expand_dir(data):
|
109 | 135 | """
|
|
0 commit comments