Ejemplo n.º 1
0
def test_basic():
    foo = Foo()

    flat_foo, refs = flatten(foo)
    foo_copy = expand(flat_foo, refs)

    assert foo == foo_copy
Ejemplo n.º 2
0
    def encode(cls, obj):
        """Birch has circular references and must be flattened."""
        flat_obj, refs = flatten(obj)

        return {
            '__mlspl_type': [type(obj).__module__, type(obj).__name__],
            'dict': flat_obj.__dict__,
            'refs': refs
        }
Ejemplo n.º 3
0
def test_loop():
    loop1 = Loop()
    loop2 = Loop()
    loop1.next = loop2
    loop2.next = loop1

    flat_loop, refs = flatten(loop1)
    foo_copy = expand(flat_loop, refs)

    assert foo_copy == foo_copy.next.next
    assert foo_copy.next == foo_copy.next.next.next