Esempio n. 1
0
def test_od_copy():

    od = OrderedDiot()
    od.i = 0
    od2 = od.copy()
    assert od2.i == 0
    od2.j = 1

    od3 = od.copy()
    assert "j" not in od3
Esempio n. 2
0
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']