Exemple #1
0
    def test_link_sorting_wheels_with_build_tags(self) -> None:
        """Verify build tags affect sorting."""
        links = [
            InstallationCandidate(
                "simplewheel",
                "2.0",
                Link("simplewheel-2.0-1-py2.py3-none-any.whl"),
            ),
            InstallationCandidate(
                "simplewheel",
                "2.0",
                Link("simplewheel-2.0-py2.py3-none-any.whl"),
            ),
            InstallationCandidate(
                "simplewheel",
                "1.0",
                Link("simplewheel-1.0-py2.py3-none-any.whl"),
            ),
        ]
        candidate_evaluator = CandidateEvaluator.create("my-project")
        sort_key = candidate_evaluator._sort_key
        results = sorted(links, key=sort_key, reverse=True)
        results2 = sorted(reversed(links), key=sort_key, reverse=True)

        assert links == results, results
        assert links == results2, results2
Exemple #2
0
    def test_link_sorting(self) -> None:
        """
        Test link sorting
        """
        links = [
            InstallationCandidate("simple", "2.0", Link("simple-2.0.tar.gz")),
            InstallationCandidate(
                "simple",
                "1.0",
                Link("simple-1.0-pyT-none-TEST.whl"),
            ),
            InstallationCandidate(
                "simple",
                "1.0",
                Link("simple-1.0-pyT-TEST-any.whl"),
            ),
            InstallationCandidate(
                "simple",
                "1.0",
                Link("simple-1.0-pyT-none-any.whl"),
            ),
            InstallationCandidate(
                "simple",
                "1.0",
                Link("simple-1.0.tar.gz"),
            ),
        ]
        valid_tags = [
            Tag("pyT", "none", "TEST"),
            Tag("pyT", "TEST", "any"),
            Tag("pyT", "none", "any"),
        ]
        specifier = SpecifierSet()
        evaluator = CandidateEvaluator(
            "my-project",
            supported_tags=valid_tags,
            specifier=specifier,
        )
        sort_key = evaluator._sort_key
        results = sorted(links, key=sort_key, reverse=True)
        results2 = sorted(reversed(links), key=sort_key, reverse=True)

        assert links == results, results
        assert links == results2, results2
Exemple #3
0
    def test_link_sorting(self):
        """
        Test link sorting
        """
        links = [
            InstallationCandidate("simple", "2.0", Link('simple-2.0.tar.gz')),
            InstallationCandidate(
                "simple",
                "1.0",
                Link('simple-1.0-pyT-none-TEST.whl'),
            ),
            InstallationCandidate(
                "simple",
                '1.0',
                Link('simple-1.0-pyT-TEST-any.whl'),
            ),
            InstallationCandidate(
                "simple",
                '1.0',
                Link('simple-1.0-pyT-none-any.whl'),
            ),
            InstallationCandidate(
                "simple",
                '1.0',
                Link('simple-1.0.tar.gz'),
            ),
        ]
        valid_tags = [
            Tag('pyT', 'none', 'TEST'),
            Tag('pyT', 'TEST', 'any'),
            Tag('pyT', 'none', 'any'),
        ]
        specifier = SpecifierSet()
        evaluator = CandidateEvaluator(
            'my-project',
            supported_tags=valid_tags,
            specifier=specifier,
        )
        sort_key = evaluator._sort_key
        results = sorted(links, key=sort_key, reverse=True)
        results2 = sorted(reversed(links), key=sort_key, reverse=True)

        assert links == results, results
        assert links == results2, results2
Exemple #4
0
    def test_build_tag_is_less_important_than_other_tags(self) -> None:
        links = [
            InstallationCandidate(
                "simple",
                "1.0",
                Link("simple-1.0-1-py3-abi3-linux_x86_64.whl"),
            ),
            InstallationCandidate(
                "simple",
                "1.0",
                Link("simple-1.0-2-py3-abi3-linux_i386.whl"),
            ),
            InstallationCandidate(
                "simple",
                "1.0",
                Link("simple-1.0-2-py3-any-none.whl"),
            ),
            InstallationCandidate(
                "simple",
                "1.0",
                Link("simple-1.0.tar.gz"),
            ),
        ]
        valid_tags = [
            Tag("py3", "abi3", "linux_x86_64"),
            Tag("py3", "abi3", "linux_i386"),
            Tag("py3", "any", "none"),
        ]
        evaluator = CandidateEvaluator(
            "my-project",
            supported_tags=valid_tags,
            specifier=SpecifierSet(),
        )
        sort_key = evaluator._sort_key
        results = sorted(links, key=sort_key, reverse=True)
        results2 = sorted(reversed(links), key=sort_key, reverse=True)

        assert links == results, results
        assert links == results2, results2
Exemple #5
0
    def test_build_tag_is_less_important_than_other_tags(self):
        links = [
            InstallationCandidate(
                "simple",
                "1.0",
                Link('simple-1.0-1-py3-abi3-linux_x86_64.whl'),
            ),
            InstallationCandidate(
                "simple",
                '1.0',
                Link('simple-1.0-2-py3-abi3-linux_i386.whl'),
            ),
            InstallationCandidate(
                "simple",
                '1.0',
                Link('simple-1.0-2-py3-any-none.whl'),
            ),
            InstallationCandidate(
                "simple",
                '1.0',
                Link('simple-1.0.tar.gz'),
            ),
        ]
        valid_tags = [
            Tag('py3', 'abi3', 'linux_x86_64'),
            Tag('py3', 'abi3', 'linux_i386'),
            Tag('py3', 'any', 'none'),
        ]
        evaluator = CandidateEvaluator(
            'my-project',
            supported_tags=valid_tags,
            specifier=SpecifierSet(),
        )
        sort_key = evaluator._sort_key
        results = sorted(links, key=sort_key, reverse=True)
        results2 = sorted(reversed(links), key=sort_key, reverse=True)

        assert links == results, results
        assert links == results2, results2