Ejemplo n.º 1
0
def test_accessor_accessor():
    """Test if accessor returns the correct Accessor object when the attr property is an accessor."""
    attr = Attr()
    attr.name = 'name'
    acc = Accessor()
    attr.attr = acc

    assert attr.accessor == acc
Ejemplo n.º 2
0
def test_accessor_name():
    """Test if accessor returns the correct Accessor object when the attr property is Falsy."""
    attr = Attr()
    attr.name = 'name'
    attr.attr = None

    acc = attr.accessor
    assert isinstance(acc, Accessor)
    assert acc.getter == attr.name
    assert acc.setter == attr.name
Ejemplo n.º 3
0
def test_accessor_callable():
    """Test if accessor returns the correct Accessor object when the attr property is a callable."""
    attr = Attr()
    attr.name = 'name'
    attr.attr = lambda x: x

    acc = attr.accessor
    assert isinstance(acc, Accessor)
    assert acc.getter == attr.attr
    assert acc.setter is None
Ejemplo n.º 4
0
def test_accessor_string():
    """Test if accessor returns the correct Accessor object when the attr property is a string."""
    attr = Attr()
    attr.name = 'name'
    attr.attr = 'attribute'

    acc = attr.accessor
    assert isinstance(acc, Accessor)
    assert acc.getter == attr.attr
    assert acc.setter == attr.attr
Ejemplo n.º 5
0
def test_key():
    """Test if the key property uses the name attribute."""
    attr = Attr()
    attr.name = 'value'
    assert attr.key == 'value'
Ejemplo n.º 6
0
def test_attr_repr():
    """Test Attr repr."""
    attr = Attr()
    attr.name = 'some'
    assert repr(attr) == "<Attr 'some'>"