def test_local_proxies_with_callables(): foo = 42 ls = Proxy(lambda: foo) assert ls == 42 foo = [23] ls.append(42) assert ls == [23, 42] assert foo == [23, 42]
def test_local_proxy_operations_list(): foo = [] ls = Proxy(lambda: foo) ls.append(42) ls.append(23) ls[1:] = [1, 2, 3] assert foo == [42, 1, 2, 3] assert repr(foo) == repr(ls) assert foo[0] == 42 foo += [1] assert list(foo) == [42, 1, 2, 3, 1] del ls[0] assert list(foo) == [1, 2, 3, 1] assert len(ls) == 4 assert list(iter(ls)) == [1, 2, 3, 1] assert 1 in ls