def test_clear(): bx = OrderedDiot() bx.a = 1 bx.c = 4 bx['g'] = 7 bx.d = 2 assert list(bx.keys()) == ['a', 'c', 'g', 'd'] bx.clear() assert bx == {} assert list(bx.keys()) == [] assert bx.__diot__['orderedkeys'] == []
def test_ordered_box(): bx = OrderedDiot(h=1) bx.a = 1 bx.c = 4 bx['g'] = 7 bx.d = 2 assert list(bx.keys()) == ['h', 'a', 'c', 'g', 'd'] del bx.a bx.pop('c') bx.__delattr__('g') assert list(bx.keys()) == ['h', 'd']
def test_inheritance_copy(): class Box2(Diot): pass b = Box2(a=1) c = b.copy() assert c == b assert isinstance(c, Diot) c = b.__copy__() assert c == b assert isinstance(c, Diot) d = OrderedDiot() d.b = 1 d.a = 0 d.x = 9 assert list(d.copy().keys()) == ['b', 'a', 'x']
def test_revesed(): bx = OrderedDiot() bx.a = 1 bx.c = 2 assert list(reversed(bx)) == ['c', 'a']
def test_iter(): bx = OrderedDiot() bx.a = 1 bx.c = 2 assert list(bx.__iter__()) == ['a', 'c']