Under the django backend, Django 1.3 does not have OperationalError
and ProgrammingError anymore (as those are specific to the MySQL
backend). So in this case, let's mock OperationalError and
ProgrammingError with DatabaseError, which is the base DB error
on Django.

This commit fixes autotest_lib.scheduler.monitor_db_functional_test

Signed-off-by: Lucas Meneghel Rodrigues <[email protected]>
---
 database/database_connection.py |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/database/database_connection.py b/database/database_connection.py
index ca5f491..53903c9 100644
--- a/database/database_connection.py
+++ b/database/database_connection.py
@@ -12,7 +12,15 @@ _GLOBAL_CONFIG_NAMES = {
 
 def _copy_exceptions(source, destination):
     for exception_name in _DB_EXCEPTIONS:
-        setattr(destination, exception_name, getattr(source, exception_name))
+        try:
+            setattr(destination, exception_name,
+                    getattr(source, exception_name))
+        except AttributeError:
+            # Under the django backend:
+            # Django 1.3 does not have OperationalError and ProgrammingError.
+            # Let's just mock these classes with the base DatabaseError.
+            setattr(destination, exception_name,
+                    getattr(source, 'DatabaseError'))
 
 
 class _GenericBackend(object):
@@ -102,7 +110,8 @@ class _SqliteBackend(_GenericBackend):
 class _DjangoBackend(_GenericBackend):
     def __init__(self):
         from django.db import backend, connection, transaction
-        super(_DjangoBackend, self).__init__(backend.Database)
+        import django.db as django_db
+        super(_DjangoBackend, self).__init__(django_db)
         self._django_connection = connection
         self._django_transaction = transaction
 
-- 
1.7.5.4

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to