Exemplo n.º 1
0
def test_normalobject():
    w1 = W_NormalObject()
    # 'setvalue' and 'getvalue' write and read the attributes by name.
    w1.setvalue('abc', W_Integer(6))
    w2 = w1.getvalue('abc')
    assert isinstance(w2, W_Integer)
    assert w2.value == 6
    # a missing attribute...
    assert w1.getvalue('bcd') is None
Exemplo n.º 2
0
def test_clone():
    w1 = W_NormalObject()
    w1.setvalue('abc', W_Integer(6))
    w2 = w1.clone()
    assert w2.getvalue('abc').value == 6
    w2.setvalue('abc', W_Integer(99))
    assert w2.getvalue('abc').value == 99
    assert w1.getvalue('abc').value == 6       # still the old value
Exemplo n.º 3
0
def test_getvalue_from_parent():
    o = W_NormalObject({'foo': W_Integer(42)})
    bar = W_NormalObject({'__parent__': o})
    assert bar.getvalue('__parent__') is o
    assert bar.getvalue('foo').value == 42