[testlib] require explicite overwriting of TestDataBaseHandler.
A new overwrite (default to False) parametters is added.
--- a/devtools/__init__.py Tue Dec 07 12:18:20 2010 +0100
+++ b/devtools/__init__.py Thu Mar 17 12:03:50 2011 +0100
@@ -698,9 +698,14 @@
HANDLERS = {}
-def register_handler(handlerkls):
+def register_handler(handlerkls, overwrite=False):
assert handlerkls is not None
- HANDLERS[handlerkls.DRIVER] = handlerkls
+ if overwrite or handlerkls.DRIVER not in HANDLERS:
+ HANDLERS[handlerkls.DRIVER] = handlerkls
+ else:
+ msg = "%s: Handler already exists use overwrite if it's intended\n"
+ "(existing handler class is %r)"
+ raise ValueError(msg % (handlerkls.DRIVER, HANDLERS[handlerkls.DRIVER]))
register_handler(PostgresTestDataBaseHandler)
register_handler(SQLiteTestDataBaseHandler)