Changed database connection duplication technique.

This new technique is more straightforward and compatible with test
parallelization, where the effective database connection settings no
longer match settings.DATABASES.
This commit is contained in:
Aymeric Augustin 2015-09-07 22:10:31 +02:00
parent e8b49d4cc4
commit 05cea7fdbb
4 changed files with 27 additions and 27 deletions

View file

@ -5,9 +5,7 @@ import time
from multiple_database.routers import TestRouter
from django.conf import settings
from django.db import connection, router, transaction
from django.db.utils import DEFAULT_DB_ALIAS, ConnectionHandler, DatabaseError
from django.db import DatabaseError, connection, router, transaction
from django.test import (
TransactionTestCase, override_settings, skipIfDBFeature,
skipUnlessDBFeature,
@ -30,8 +28,7 @@ class SelectForUpdateTests(TransactionTestCase):
# We need another database connection in transaction to test that one
# connection issuing a SELECT ... FOR UPDATE will block.
new_connections = ConnectionHandler(settings.DATABASES)
self.new_connection = new_connections[DEFAULT_DB_ALIAS]
self.new_connection = connection.copy()
def tearDown(self):
try: