@testing.requires.predictable_gc
    def test_weakref(self):

        users, User = self.tables.users, self.classes.User


        s = create_session()
        mapper(User, users)

        s.add(User(name='ed'))
        s.flush()
        assert not s.dirty

        user = s.query(User).one()
        del user
        gc_collect()
        assert len(s.identity_map) == 0

        user = s.query(User).one()
        user.name = 'fred'
        del user
        gc_collect()
        assert len(s.identity_map) == 1
        assert len(s.dirty) == 1
        assert None not in s.dirty
        s.flush()
        gc_collect()
        assert not s.dirty
        assert not s.identity_map

        user = s.query(User).one()
        assert user.name == 'fred'
        assert s.identity_map
test the weak-referencing identity map, which strongly-
dataset/ETHPy150Open zzzeek/sqlalchemy/test/orm/test_session.py/WeakIdentityMapTest.test_weakref