Example #1
0
 def test_evaluate_link__allow_yanked(
     self, yanked_reason, allow_yanked, expected,
 ):
     target_python = TargetPython(py_version_info=(3, 6, 4))
     evaluator = LinkEvaluator(
         project_name='twine',
         canonical_name='twine',
         formats={'source'},
         target_python=target_python,
         allow_yanked=allow_yanked,
     )
     link = Link(
         'https://example.com/#egg=twine-1.12',
         yanked_reason=yanked_reason,
     )
     actual = evaluator.evaluate_link(link)
     assert actual == expected
Example #2
0
 def make_test_link_evaluator(self, formats):
     target_python = TargetPython()
     return LinkEvaluator(
         project_name='pytest',
         canonical_name='pytest',
         formats=formats,
         target_python=target_python,
         allow_yanked=True,
     )
Example #3
0
 def test_evaluate_link(
     self, py_version_info, ignore_requires_python, expected,
 ):
     target_python = TargetPython(py_version_info=py_version_info)
     evaluator = LinkEvaluator(
         project_name='twine',
         canonical_name='twine',
         formats={'source'},
         target_python=target_python,
         allow_yanked=True,
         ignore_requires_python=ignore_requires_python,
     )
     link = Link(
         'https://example.com/#egg=twine-1.12',
         requires_python='== 3.6.5',
     )
     actual = evaluator.evaluate_link(link)
     assert actual == expected
Example #4
0
 def make_test_link_evaluator(self, formats: Iterable[str]) -> LinkEvaluator:
     target_python = TargetPython()
     return LinkEvaluator(
         project_name="pytest",
         canonical_name="pytest",
         formats=frozenset(formats),
         target_python=target_python,
         allow_yanked=True,
     )
Example #5
0
 def test_evaluate_link__incompatible_wheel(self):
     """
     Test an incompatible wheel.
     """
     target_python = TargetPython(py_version_info=(3, 6, 4))
     # Set the valid tags to an empty list to make sure nothing matches.
     target_python._valid_tags = []
     evaluator = LinkEvaluator(
         project_name='sample',
         canonical_name='sample',
         formats={'binary'},
         target_python=target_python,
         allow_yanked=True,
     )
     link = Link('https://example.com/sample-1.0-py2.py3-none-any.whl')
     actual = evaluator.evaluate_link(link)
     expected = (
         False,
         "none of the wheel's tags match: py2-none-any, py3-none-any")
     assert actual == expected
Example #6
0
 def test_evaluate_link__allow_yanked(
     self,
     yanked_reason: str,
     allow_yanked: bool,
     expected: Tuple[bool, str],
 ) -> None:
     target_python = TargetPython(py_version_info=(3, 6, 4))
     evaluator = LinkEvaluator(
         project_name="twine",
         canonical_name="twine",
         formats=frozenset(["source"]),
         target_python=target_python,
         allow_yanked=allow_yanked,
     )
     link = Link(
         "https://example.com/#egg=twine-1.12",
         yanked_reason=yanked_reason,
     )
     actual = evaluator.evaluate_link(link)
     assert actual == expected
Example #7
0
 def test_evaluate_link(
     self,
     py_version_info: Tuple[int, int, int],
     ignore_requires_python: bool,
     expected: Tuple[bool, Optional[str]],
 ) -> None:
     target_python = TargetPython(py_version_info=py_version_info)
     evaluator = LinkEvaluator(
         project_name="twine",
         canonical_name="twine",
         formats=frozenset(["source"]),
         target_python=target_python,
         allow_yanked=True,
         ignore_requires_python=ignore_requires_python,
     )
     link = Link(
         "https://example.com/#egg=twine-1.12",
         requires_python="== 3.6.5",
     )
     actual = evaluator.evaluate_link(link)
     assert actual == expected
Example #8
0
 def test_evaluate_link__incompatible_wheel(self) -> None:
     """
     Test an incompatible wheel.
     """
     target_python = TargetPython(py_version_info=(3, 6, 4))
     # Set the valid tags to an empty list to make sure nothing matches.
     target_python._valid_tags = []
     evaluator = LinkEvaluator(
         project_name="sample",
         canonical_name="sample",
         formats=frozenset(["binary"]),
         target_python=target_python,
         allow_yanked=True,
     )
     link = Link("https://example.com/sample-1.0-py2.py3-none-any.whl")
     actual = evaluator.evaluate_link(link)
     expected = (
         False,
         "none of the wheel's tags (py2-none-any, py3-none-any) are compatible "
         "(run pip debug --verbose to show compatible tags)",
     )
     assert actual == expected