Example #1
0
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'] == []
Example #2
0
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']
Example #3
0
def test_revesed():
    bx = OrderedDiot()
    bx.a = 1
    bx.c = 2
    assert list(reversed(bx)) == ['c', 'a']
Example #4
0
def test_iter():
    bx = OrderedDiot()
    bx.a = 1
    bx.c = 2
    assert list(bx.__iter__()) == ['a', 'c']