示例#1
0
def test_include_max_prerelease(v200, v300, v300b1):
    result = VersionRange(v200, v300)

    assert not result.allows(v300b1)
    assert not result.allows_any(VersionRange(v300b1))
    assert not result.allows_all(VersionRange(v200, v300b1))

    result = VersionRange(v200, v300, always_include_max_prerelease=True)

    assert result.allows(v300b1)
    assert result.allows_any(VersionRange(v300b1))
    assert result.allows_all(VersionRange(v200, v300b1))
示例#2
0
def test_union(v003, v010, v072, v080, v114, v123, v124, v130, v140, v200,
               v234, v250, v300):
    # with a version returns the range if it contains the version
    range = VersionRange(v114, v124)
    assert range.union(v123) == range

    # with a version on the edge of the range, expands the range
    range = VersionRange(v114, v124)
    assert range.union(v124) == VersionRange(v114, v124, include_max=True)
    assert range.union(v114) == VersionRange(v114, v124, include_min=True)

    # with a version allows both the range and the version if the range
    # doesn't contain the version
    result = VersionRange(v003, v114).union(v124)
    assert result.allows(v010)
    assert not result.allows(v123)
    assert result.allows(v124)

    # returns a VersionUnion for a disjoint range
    result = VersionRange(v003, v114).union(VersionRange(v130, v200))
    assert result.allows(v080)
    assert not result.allows(v123)
    assert result.allows(v140)

    # considers open ranges disjoint
    result = VersionRange(v003, v114).union(VersionRange(v114, v200))
    assert result.allows(v080)
    assert not result.allows(v114)
    assert result.allows(v140)
    result = VersionRange(v114, v200).union(VersionRange(v003, v114))
    assert result.allows(v080)
    assert not result.allows(v114)
    assert result.allows(v140)

    # returns a merged range for an overlapping range
    result = VersionRange(v003, v114).union(VersionRange(v080, v200))
    assert result == VersionRange(v003, v200)

    # considers closed ranges overlapping
    result = VersionRange(v003, v114,
                          include_max=True).union(VersionRange(v114, v200))
    assert result == VersionRange(v003, v200)
    result = VersionRange(v003, v114).union(
        VersionRange(v114, v200, include_min=True))
    assert result == VersionRange(v003, v200)