diff roundup/backends/__init__.py @ 6365:7f00fc5958ca

Make memorydb persistent across re-open This allows memorydb to be used for more tests, in particular re-opening with another user for checking permissions.
author Ralf Schlatterbeck <rsc@runtux.com>
date Wed, 31 Mar 2021 12:49:28 +0200
parents 22eecc8a8bd4
children 95f91b6f0386
line wrap: on
line diff
--- a/roundup/backends/__init__.py	Tue Mar 30 21:04:53 2021 -0400
+++ b/roundup/backends/__init__.py	Wed Mar 31 12:49:28 2021 +0200
@@ -54,6 +54,9 @@
         else:
             modname = e.args[0][16:] if e.args[0].startswith('No module named ') else None
 
+        # It's always ok if memorydb is not found
+        if modname.endswith('back_memorydb'):
+            return 0
         if modname and (modname in _modules.get(name, (name,))):
             return 0
         raise
@@ -65,9 +68,15 @@
     This function has side-effect of registering backward-compatible
     globals for all available backends.
 
+    Note: Since memorydb does not live in the backends directory, it will
+    never be found in the default setup. It *can* be enabled by preloading
+    test/memorydb and injecting into roundup.backends. So the normal user
+    can never configure memorydb but it makes using the tests easier
+    because we do not need to monkey-patch list_backends.
+
     '''
     l = []
-    for name in 'anydbm', 'mysql', 'sqlite', 'postgresql':
+    for name in 'anydbm', 'mysql', 'sqlite', 'postgresql', 'memorydb':
         if have_backend(name):
             l.append(name)
     return l

Roundup Issue Tracker: http://roundup-tracker.org/