def test_lazy_property():
    poison = False

    class Foo(object):

        @util.lazy_property
        def squiznart(self):
            assert not poison
            return 'abc'

    assert Foo.squiznart != 'abc'
    assert hasattr(Foo.squiznart, '__get__')

    f = Foo()
    assert 'squiznart' not in f.__dict__
    assert f.squiznart == 'abc'
    assert f.__dict__['squiznart'] == 'abc'

    poison = True
    assert f.squiznart == 'abc'

    new_foo = Foo()
    assert_raises(AssertionError, getattr, new_foo, 'squiznart')
    assert 'squiznart' not in new_foo.__dict__
dataset/ETHPy150Open jek/flatland/tests/test_utils.py/test_lazy_property/original