Exemplo n.º 1
0
def test_ObjDict__getattr__():
    """Test :func:`~utilipy.utils.collections.ObjDict.__getattr__`."""
    _c = ObjDict("inner", a="A")
    od = ObjDict(name="name", a=1, b=None, c=_c)

    assert od.__getattr__("a") == 1
    assert od.__getattr__("b") is None
    assert od.__getattr__("c").__getattr__("a") == "A"

    with pytest.raises(KeyError):
        assert od.__getattr__("name")  # only by __getattribute__

    return
Exemplo n.º 2
0
def test_ObjDict__setattr__():
    """Test :func:`~utilipy.utils.collections.ObjDict.__setattr__`."""
    # make ObjDict
    od = ObjDict()
    od.__setattr__("a", 1)

    # test
    assert od.__getattr__("a") == 1

    return