# HG changeset patch # User Pierre-Yves David # Date 1300360028 -3600 # Node ID 8052d2452b9c014a60534018d1be3e9009cece93 # Parent 6c6e0fbd0605af408c15d357796fb4ab990732c2# Parent d9e6e79e023a802b10e5597b8eb490ba0ab7102c merge: [testlib] require explicite overwriting of TestDataBaseHandler. A new overwrite (default to False) parametters is added. diff -r 6c6e0fbd0605 -r 8052d2452b9c devtools/__init__.py --- a/devtools/__init__.py Thu Mar 17 11:38:52 2011 +0100 +++ b/devtools/__init__.py Thu Mar 17 12:07:08 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)