Add support for removing file format backends.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
This commit is contained in:
parent
8c71535123
commit
bb3f89f9b0
2 changed files with 13 additions and 0 deletions
|
|
@ -567,6 +567,13 @@ class FileStorage:
|
||||||
def register_backend(klass, name, obj):
|
def register_backend(klass, name, obj):
|
||||||
klass.BACKENDS[name] = obj
|
klass.BACKENDS[name] = obj
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def unregister_backend(klass, name):
|
||||||
|
try:
|
||||||
|
del klass.BACKENDS[name]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _canonicalize_transaction_types(types):
|
def _canonicalize_transaction_types(types):
|
||||||
if types is None:
|
if types is None:
|
||||||
|
|
|
||||||
|
|
@ -262,6 +262,12 @@ class PluggableBackendsTest(unittest.TestCase):
|
||||||
self.assertEqual(len(recs), 1)
|
self.assertEqual(len(recs), 1)
|
||||||
self.assertEqual(recs[0].fields, ['a', 'b'])
|
self.assertEqual(recs[0].fields, ['a', 'b'])
|
||||||
|
|
||||||
|
def test_removing_backend(self):
|
||||||
|
FileStorage.register_backend('example', ExampleFile)
|
||||||
|
self.assertEqual(FileStorage.BACKENDS['example'], ExampleFile)
|
||||||
|
FileStorage.unregister_backend('example')
|
||||||
|
with self.assertRaises(KeyError):
|
||||||
|
FileStorage.BACKENDS['example']
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue