MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_rebuild_state

Method test_rebuild_state

test/orm/test_pickled.py:869–884  ·  view source on GitHub ↗

not much of a 'test', but illustrate how to remove instance-level state before pickling.

(self)

Source from the content-addressed store, hash-verified

867 )
868
869 def test_rebuild_state(self):
870 """not much of a 'test', but illustrate how to
871 remove instance-level state before pickling.
872
873 """
874
875 users = self.tables.users
876
877 self.mapper_registry.map_imperatively(User, users)
878
879 u1 = User()
880 attributes.manager_of_class(User).teardown_instance(u1)
881 assert not u1.__dict__
882 u2 = pickle.loads(pickle.dumps(u1))
883 attributes.manager_of_class(User).setup_instance(u2)
884 assert attributes.instance_state(u2)

Callers

nothing calls this directly

Calls 7

UserClass · 0.90
map_imperativelyMethod · 0.80
manager_of_classMethod · 0.80
teardown_instanceMethod · 0.45
loadsMethod · 0.45
dumpsMethod · 0.45
setup_instanceMethod · 0.45

Tested by

no test coverage detected