def test_pickle(self): objects = select(s for s in Student if s.scholarship > 0).order_by(desc(Student.id)) data = pickle.dumps(objects) rollback() objects = pickle.loads(data) self.assertEqual([obj.id for obj in objects], [3, 2])
def test_pickle(self): with db_session: p1 = Product.select().first() data = pickle.dumps(p1) with db_session: p1 = pickle.loads(data) p1.name = 'name2' flush() rollback()
def test_multiset_reduce(self): with db_session: d = Department[1] multiset = d.groups.students s = pickle.dumps(multiset) with db_session: d = Department[1] multiset_2 = d.groups.students multiset_1 = pickle.loads(s) self.assertEqual(multiset_1, multiset_2)