Ejemplo n.º 1
0
def test_basic_proxy_attribute_management_and_picklability():
    """Contained-object proxy

    This is a picklable proxy that can be put around objects that
    don't implement IContained.
    """
    l = [1, 2, 3]
    p = ContainedProxy(l)
    p.__parent__ = 'Dad'
    p.__name__ = 'p'

    assert p == [1, 2, 3]
    assert p.__parent__ == 'Dad'
    assert p.__name__ == 'p'
    'p'

    with pytest.raises(TypeError):
        # A proxy is not pickable.
        pickle.loads(pickle.dumps(p))