Exemple #1
0
def _(operand):
    if all(isinstance(item, Register) for item in operand):
        return Registers(operand)
    elif all(isinstance(item, (Integral, Label)) for item in operand):
        return Integers(operand)
    else:
        raise TypeError("{} could not be parsed".format(operand))
def test_integers_equal_hash(items):
    assert hash(Integers(items)) == hash(Integers(items))
def test_integers_inequality(items_a, items_b):
    assume(items_a != items_b)
    assert Integers(items_a) != Integers(items_b)
def test_integers_inequality_different_types(items):
    assert Integers(items) != object()
def test_integers_equality(items):
    assert Integers(items) == Integers(items)
def test_integers_repr(items):
    r = repr(Integers(items))
    assert r.startswith('Integers')
    assert check_balanced(r)
def test_items_are_integers():
    with raises(TypeError):
        Integers(["hello"])
def test_integers_empty_raises_value_error():
    with raises(ValueError):
        Integers([])
def test_integers_values(items):
    assert list(Integers(items)) == items