예제 #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
예제 #2
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
예제 #3
0
    def test_specifiers_normalized(self, version):
        if "+" not in version:
            ops = ["~=", "==", "!=", "<=", ">=", "<", ">"]
        else:
            ops = ["==", "!="]

        for op in ops:
            PythonSpecifier(op + version)
예제 #4
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
예제 #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))
예제 #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)
예제 #7
0
 def test_specifiers_invalid(self, specifier):
     with pytest.raises(InvalidSpecifier):
         PythonSpecifier(specifier)
예제 #8
0
 def test_specifier_version_property(self, spec, version):
     assert PythonSpecifier(spec).version == version
예제 #9
0
 def test_specifier_operator_property(self, spec, op):
     assert PythonSpecifier(spec).operator == op
예제 #10
0
 def test_specifier_explicit_loose(self):
     assert PythonSpecifier("==1.0").contains(LooseVersion("1.0"))
예제 #11
0
 def test_specifiers_hash(self, specifier):
     assert (hash(PythonSpecifier(specifier)) == hash(
         PythonSpecifier(specifier)))
예제 #12
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)
예제 #13
0
 def test_specifier_prereleases_detection(self, specifier, expected):
     assert PythonSpecifier(specifier).prereleases == expected
예제 #14
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))
예제 #15
0
 def test_specifiers_valid(self, specifier):
     PythonSpecifier(specifier)
예제 #16
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"
예제 #17
0
 def test_comparison_canonicalizes(self, left, right):
     assert PythonSpecifier(left) == PythonSpecifier(right)
     assert left == PythonSpecifier(right)
     assert PythonSpecifier(left) == right