コード例 #1
0
 def test_set_subclass_with_data(self):
     obj = SetSubclass([1, 2, 3])
     data = ListSubclass()
     data.extend([1, 2, 3])
     obj.data = data
     flattened = self.pickler.flatten(obj)
     restored = self.unpickler.restore(flattened)
     self.assertEqual(type(restored.data), ListSubclass)
     self.assertEqual(restored.data, data)
コード例 #2
0
 def test_set_subclass_with_data(self):
     obj = SetSubclass([1, 2, 3])
     data = ListSubclass()
     data.extend([1, 2, 3])
     obj.data = data
     flattened = self.pickler.flatten(obj)
     restored = self.unpickler.restore(flattened)
     self.assertEqual(type(restored.data), ListSubclass)
     self.assertEqual(restored.data, data)
コード例 #3
0
 def test_list_subclass(self):
     obj = ListSubclass()
     obj.extend([1, 2, 3])
     flattened = self.pickler.flatten(obj)
     self.assertTrue(tags.OBJECT in flattened)
     self.assertTrue(tags.SEQ in flattened)
     self.assertEqual(len(flattened[tags.SEQ]), 3)
     for v in obj:
         self.assertTrue(v in flattened[tags.SEQ])
     restored = self.unpickler.restore(flattened)
     self.assertEqual(type(restored), ListSubclass)
     self.assertEqual(restored, obj)
コード例 #4
0
 def test_list_subclass(self):
     obj = ListSubclass()
     obj.extend([1, 2, 3])
     flattened = self.pickler.flatten(obj)
     self.assertTrue(tags.OBJECT in flattened)
     self.assertTrue(tags.SEQ in flattened)
     self.assertEqual(len(flattened[tags.SEQ]), 3)
     for v in obj:
         self.assertTrue(v in flattened[tags.SEQ])
     restored = self.unpickler.restore(flattened)
     self.assertEqual(type(restored), ListSubclass)
     self.assertEqual(restored, obj)
コード例 #5
0
 def test_is_sequence_subclass_subclass(self):
     self.assertTrue(is_sequence_subclass(ListSubclass()))
コード例 #6
0
ファイル: util_tests.py プロジェクト: yupingzhang/jsonpickle
 def test_subclass(self):
     self.assertTrue(is_collection_subclass(ListSubclass()))