def test_register_unregister(self): """Register/unregister serializers""" serializers = {} for name in self.serializers: serializer = manager.serializer(name) self._is_serializer(serializer) for name in self.serializers: serializer = manager.unregister(name) self._is_serializer(serializer) serializers[name] = serializer for name in self.serializers: self.assertEqual(manager.serializer(name), None) for name in self.serializers: with self.assertRaises(ValueError): manager.unregister(name) for name in self.serializers: serializer = serializers[name] manager.register(name, serializer)
def test_serialization(self): """Dump/load data""" data = {'arg1': 'value1', 'arg2': 'value2'} for name in self.serializers: serializer = manager.serializer(name) path = os.path.join(self.tempdir, 'test.{}'.format(name)) self.assertFalse(os.path.exists(path)) with open(path, 'wb') as file_obj: serializer.dump(data, file_obj) self.assertTrue(os.path.exists(path)) with open(path, 'rb') as file_obj: data2 = serializer.load(file_obj) self.assertEqual(data, data2) os.unlink(path)
def test_default_serializers(): """Default serializers.""" for name in SERIALIZERS: assert is_serializer(default_manager.serializer(name)) assert set(SERIALIZERS) == set(default_manager.serializers)
def test_default_serializers(self): """Default serializers""" for name in self.serializers: self._is_serializer(manager.serializer(name)) self.assertEqual(set(self.serializers), set(manager.serializers))