示例#1
0
def test_or__init__non_check_value():
    with pytest.raises(ValueError):
        versions.Or(versions.LT(2), None)
示例#2
0
def test_or__check_version__insufficient_number_of_values__is_lazy():
    obj_1 = versions.GE(1, 2)
    obj_2 = versions.LT(2, 0, 1)
    obj = versions.Or(obj_1, obj_2)
    assert obj((1, 3))
示例#3
0
        assert False  # pragma: no coverage
    except versions.VersionRequirementError as error:
        assert str(error) == expected


###############################################################################
###############################################################################
# Pickling of checks

_CAN_PICKLE_VALUES = (
    versions.EQ(1, 2, 3),
    versions.GE(1, 2, 3),
    versions.LT(1, 2, 3),
    versions.Any(),
    versions.And(versions.EQ(1, 2, 3)),
    versions.Or(versions.GE(1, 2, 3)),
)


@pytest.mark.parametrize("obj", _CAN_PICKLE_VALUES)
def test_check__can_pickle(obj):
    pickle.dumps(obj)


###############################################################################
###############################################################################
# Requirement


def test_requirement__obj_is_cached_for_same_values():
    obj1 = versions.Requirement("echo", "", versions.LT(1))
示例#4
0
 def _do_or_check_truncated(obj_1, obj_2):
     obj = versions.Or(obj_1, obj_2)
     assert obj((1, 3, 3))
示例#5
0
 def _do_or_check_num_values(obj_1, obj_2):
     obj = versions.Or(obj_1, obj_2)
     assert_raises(ValueError, obj, (1, 3))
示例#6
0
def test_or__check_version__neither_true():
    obj_1 = versions.And(versions.GE(1, 2), versions.LT(2, 0))
    obj_2 = versions.And(versions.GE(2, 3), versions.LT(3, 0))
    obj = versions.Or(obj_1, obj_2)
    assert not obj((2, 2))
示例#7
0
def test_or__check_version__second_true():
    obj_1 = versions.And(versions.GE(1, 2), versions.LT(2, 0))
    obj_2 = versions.And(versions.GE(2, 3), versions.LT(3, 0))
    obj = versions.Or(obj_1, obj_2)
    assert obj((2, 3))
示例#8
0
def test_or__check_version__both_true():
    obj_1 = versions.GE(1, 2)
    obj_2 = versions.LT(2, 0)
    obj = versions.Or(obj_1, obj_2)
    assert obj((1, 3))
示例#9
0
def test_or__str__two_items():
    obj_ge = versions.GE(1, 2)
    obj_lt = versions.LT(3, 4)
    obj = versions.Or(obj_ge, obj_lt)

    assert_equal(str(obj), "at least v1.2.x or prior to v3.4.x")
示例#10
0
def test_or__str__single_item():
    obj = versions.Or(versions.GE(1))
    assert_equal(str(obj), "at least v1.x")