Permalink
Browse files

database.database_connection: Fix _copy_exceptions

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 <lmr@redhat.com>


git-svn-id: svn://test.kernel.org/autotest/trunk@5438 592f7852-d20e-0410-864c-8624ca9c26a4
  • Loading branch information...
1 parent 7136ad2 commit bbcc4031b0069c2248094b62c0fe2e26356d65ad lmr committed Jun 22, 2011
Showing with 11 additions and 2 deletions.
  1. +11 −2 database/database_connection.py
@@ -12,7 +12,15 @@
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 @@ def execute(self, query, parameters=None):
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

0 comments on commit bbcc403

Please sign in to comment.