示例#1
0
    def test_exclusive_upper_bound(self):
        vr = VersionRange("[1.0,2.0)")
        assert len(vr.restrictions) == 1
        assert vr.version is None

        vr = VersionRange("[1.5,)")
        assert len(vr.restrictions) == 1
        assert vr.version is None
示例#2
0
    def test_inclusive_range(self):
        vr = VersionRange("[1.0]")
        assert len(vr.restrictions) == 1
        assert vr.version is None

        vr = VersionRange("[1.2,1.3]")
        assert len(vr.restrictions) == 1
        assert vr.version is None
示例#3
0
 def test_match_versions(self):
     versions = [
         Version("0.1"),
         Version("1.0"),
         Version("1.1"),
         Version("2.0"),
         Version("2.1")
     ]
     vr = VersionRange("(1.0,2.0]")
     assert vr.match_version(versions) == "2.0"
     assert vr.match_version(versions[:3]) == "1.1"
示例#4
0
    def test_snapshots(self):
        vr = VersionRange("[1.0,)")
        assert "1.0-SNAPSHOT" not in vr

        vr = VersionRange("[1.0,1.1-SNAPSHOT]")
        assert "1.1-SNAPSHOT" in vr

        vr = VersionRange("[1.0,1.2]")
        assert "1.0-SNAPSHOT" not in vr
        assert "1.1-SNAPSHOT" in vr
        assert "1.2-SNAPSHOT" in vr
        assert "1.3-SNAPSHOT" not in vr

        vr = VersionRange("[1.0,1.2-SNAPSHOT]")
        assert "1.1-SNAPSHOT" in vr
        assert "1.2-SNAPSHOT" in vr

        vr = VersionRange("[1.0-SNAPSHOT,1.2]")
        assert "1.0-SNAPSHOT" in vr
        assert "1.1-SNAPSHOT" in vr

        vr = VersionRange("1.0-SNAPSHOT")
        assert "1.0-SNAPSHOT" in vr

        vr = VersionRange("[0.1,1.0)")
        assert "0.1" in vr
        assert "0.1.0" in vr
        assert "0.1-SNAPSHOT" not in vr
        assert "0.1.0-SNAPSHOT" not in vr
示例#5
0
    def test_contains(self):
        test_pairs = (
            ("2.0.5", True),
            ("2.0.4", True),
            ("[2.0.5]", True),
            ("[2.0.6,)", False),
            ("[2.0.6]", False),
            ("2.0,2.1]", True),
            ("[2.0,2.0.3]", False),
            ("[2.0,2.0.5]", True),
            ("[2.0,2.0.5)", False),
        )
        v = Version("2.0.5")
        for spec, expected in test_pairs:
            vr = VersionRange(spec)
            assert (v in vr) == expected
            assert ("2.0.5" in vr) == expected

        assert VersionRange("2.0.5") in \
            VersionRange("[2.0,3.0)")

        assert VersionRange("[2.0.5]") not in \
            VersionRange("[2.0,3.0)")
示例#6
0
 def test_match_versions(self):
     versions = [Version("0.1"), Version("1.0"), Version("1.1"),
                 Version("2.0"), Version("2.1")]
     vr = VersionRange("(1.0,2.0]")
     assert vr.match_version(versions) == "2.0"
     assert vr.match_version(versions[:3]) == "1.1"
示例#7
0
    def test_fromversion(self):
        v = Version("1.0")
        vr = VersionRange.from_version(v)

        assert vr.version == v
示例#8
0
    def test_fromversion(self):
        v = Version("1.0")
        vr = VersionRange.from_version(v)

        assert vr.version == v
示例#9
0
 def test_str(self):
     for input in ("[1.0,2.0]", "1.0"):
         actual = str(VersionRange(input))
         assert input == actual, \
             "VersionRange(%s) == %s, wanted %s" % (input, actual, input)
示例#10
0
    def test_compare(self):
        vr1 = VersionRange("(1.0,2.0]")

        assert vr1 == vr1
        assert vr1 == "(1.0,2.0]"
        assert 1 < vr1
示例#11
0
 def test_long_version(self):
     vr = VersionRange("[5.0.9.0,5.0.10.0)")
     assert Version("5.0.9.0") in vr
     assert "5.0.9.0" in vr
示例#12
0
 def test_multiple_restrictions(self):
     vr = VersionRange("(,1.0],[1.2,)")
     assert len(vr.restrictions) == 2
     assert vr.version is None
示例#13
0
 def test_single_spec(self):
     vr = VersionRange("1.0")
     assert len(vr.restrictions) == 1
     assert str(vr.version) == "1.0"
示例#14
0
 def test_no_lower_limit(self):
     vr = VersionRange("(,1.0]")
     assert len(vr.restrictions) == 1
     assert vr.version is None
示例#15
0
 def test_compare(self):
     assert 1 < Version("1.0")
     assert VersionRange("1.0") == Version("1.0")