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)
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)
def test_is_sequence_subclass_subclass(self): self.assertTrue(is_sequence_subclass(ListSubclass()))
def test_subclass(self): self.assertTrue(is_collection_subclass(ListSubclass()))