Exemplo n.º 1
0
    def test_specifier_filter(self, specifier, prereleases, input, expected):
        spec = PythonSpecifier(specifier)

        kwargs = ({
            "prereleases": prereleases
        } if prereleases is not None else {})

        assert list(spec.filter(input, **kwargs)) == expected
Exemplo n.º 2
0
    def test_specifiers_normalized(self, version):
        if "+" not in version:
            ops = ["~=", "==", "!=", "<=", ">=", "<", ">"]
        else:
            ops = ["==", "!="]

        for op in ops:
            PythonSpecifier(op + version)
Exemplo n.º 3
0
    def test_specifiers_identity(self, version, spec, expected):
        spec = PythonSpecifier(spec)

        if expected:
            # Identity comparisons only support the plain string form
            assert version in spec
        else:
            # Identity comparisons only support the plain string form
            assert version not in spec
Exemplo n.º 4
0
    def test_specifiers_prereleases(self, specifier, version, expected):
        spec = PythonSpecifier(specifier)

        if expected:
            assert version in spec
            spec.prereleases = False
            assert version not in spec
        else:
            assert version not in spec
            spec.prereleases = True
            assert version in spec
Exemplo n.º 5
0
    def test_specifiers(self, version, spec, expected):
        spec = PythonSpecifier(spec, prereleases=True)

        if expected:
            # Test that the plain string form works
            assert version in spec
            assert spec.contains(version)

            # Test that the version instance form works
            assert PythonVersion(version) in spec
            assert spec.contains(PythonVersion(version))
        else:
            # Test that the plain string form works
            assert version not in spec
            assert not spec.contains(version)

            # Test that the version instance form works
            assert PythonVersion(version) not in spec
            assert not spec.contains(PythonVersion(version))
Exemplo n.º 6
0
 def test_comparison_false(self, left, right, op):
     assert not op(PythonSpecifierSet(left), PythonSpecifierSet(right))
     assert not op(PythonSpecifierSet(left), PythonSpecifier(right))
     assert not op(PythonSpecifier(left), PythonSpecifierSet(right))
     assert not op(left, PythonSpecifierSet(right))
     assert not op(PythonSpecifierSet(left), right)
Exemplo n.º 7
0
 def test_specifiers_invalid(self, specifier):
     with pytest.raises(InvalidSpecifier):
         PythonSpecifier(specifier)
Exemplo n.º 8
0
 def test_specifier_version_property(self, spec, version):
     assert PythonSpecifier(spec).version == version
Exemplo n.º 9
0
 def test_specifier_operator_property(self, spec, op):
     assert PythonSpecifier(spec).operator == op
Exemplo n.º 10
0
 def test_specifier_explicit_loose(self):
     assert PythonSpecifier("==1.0").contains(LooseVersion("1.0"))
Exemplo n.º 11
0
 def test_specifiers_hash(self, specifier):
     assert (hash(PythonSpecifier(specifier)) == hash(
         PythonSpecifier(specifier)))
Exemplo n.º 12
0
 def test_specifier_prereleases_detection(self, specifier, expected):
     assert PythonSpecifier(specifier).prereleases == expected
Exemplo n.º 13
0
    def test_specifiers_str_and_repr(self, specifier, expected):
        spec = PythonSpecifier(specifier)

        assert str(spec) == expected
        assert repr(spec) == "<PythonSpecifier({0})>".format(repr(expected))
Exemplo n.º 14
0
 def test_specifiers_valid(self, specifier):
     PythonSpecifier(specifier)
Exemplo n.º 15
0
 def test_comparison_non_specifier(self):
     assert PythonSpecifier("==1.0") != 12
     assert not PythonSpecifier("==1.0") == 12
     assert PythonSpecifier("==1.0") != "12"
     assert not PythonSpecifier("==1.0") == "12"
Exemplo n.º 16
0
 def test_comparison_canonicalizes(self, left, right):
     assert PythonSpecifier(left) == PythonSpecifier(right)
     assert left == PythonSpecifier(right)
     assert PythonSpecifier(left) == right
Exemplo n.º 17
0
 def test_comparison_true(self, left, right, op):
     assert op(PythonSpecifier(left), PythonSpecifier(right))
     assert op(left, PythonSpecifier(right))
     assert op(PythonSpecifier(left), right)