def test_lazyhistory(self):

        class Foo(fixtures.BasicEntity):
            pass
        class Bar(fixtures.BasicEntity):
            pass

        instrumentation.register_class(Foo)
        instrumentation.register_class(Bar)
        bar1, bar2, bar3, bar4 = [Bar(id=1), Bar(id=2), Bar(id=3),
                                  Bar(id=4)]

        def func1(state, passive):
            return 'this is func 1'

        def func2(state, passive):
            return [bar1, bar2, bar3]

        attributes.register_attribute(Foo, 'col1', uselist=False,
                callable_=func1, useobject=True)
        attributes.register_attribute(Foo, 'col2', uselist=True,
                callable_=func2, useobject=True)
        attributes.register_attribute(Bar, 'id', uselist=False,
                useobject=True)
        x = Foo()
        attributes.instance_state(x)._commit_all(attributes.instance_dict(x))
        x.col2.append(bar4)
        eq_(attributes.get_state_history(attributes.instance_state(x),
            'col2'), ([bar4], [bar1, bar2, bar3], []))
tests that history functions work with lazy-loading attributes
dataset/ETHPy150Open zzzeek/sqlalchemy/test/orm/test_attributes.py/AttributesTest.test_lazyhistory