Ejemplo n.º 1
0
def test_box():
    name = 'Boxed variable'
    val = Value(0, 0, 0)
    exp = Box(name, val)
    assert all(exp == (0, 0, 0))
    assert exp.pretty_name == name
    val.fix(3, 3, 3)
    assert all(exp == (3, 3, 3))
    exp.value = Value(6, 6, 6)
    assert all(exp == (6, 6, 6))
Ejemplo n.º 2
0
def test_box_recursion(check_dump):
    val = Value(0, 0, 0)
    exp = Box('Box with itself inside', val)
    exp.value = exp
    with pytest.raises(RuntimeError):
        exp.get()
    if sys.version_info >= (3, 5):
        exc_name = 'RecursionError'
    else:
        exc_name = 'RuntimeError'
    check_dump(exp, """
        Box with itself inside <{e} while getting value>:  (&1)
          Box with itself inside <{e} while getting value>  (*1)
    """.format(e=exc_name))