summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBertrand Bordage <bordage.bertrand@gmail.com>2017-06-03 15:48:59 (GMT)
committerBertrand Bordage <bordage.bertrand@gmail.com>2017-06-03 15:48:59 (GMT)
commitd0ee580cf33df472599338755db6a2b933191c2d (patch)
tree6e87573e2c3b354cc2b14a0f2b9f4e5806bd0f58
parent542a5b60978b4400f5a63a6f6ff8eb739be959af (diff)
downloaddjango-cachalot-d0ee580cf33df472599338755db6a2b933191c2d.zip
django-cachalot-d0ee580cf33df472599338755db6a2b933191c2d.tar.gz
django-cachalot-d0ee580cf33df472599338755db6a2b933191c2d.tar.bz2
Fixes multi-databases tests.
-rw-r--r--cachalot/tests/multi_db.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/cachalot/tests/multi_db.py b/cachalot/tests/multi_db.py
index a9833b8..c189456 100644
--- a/cachalot/tests/multi_db.py
+++ b/cachalot/tests/multi_db.py
@@ -8,17 +8,14 @@ from django.db import DEFAULT_DB_ALIAS, connections, transaction
from django.test import TransactionTestCase
from .models import Test
-from .test_utils import TestUtilsMixin
@skipIf(len(settings.DATABASES) == 1,
'We can’t change the DB used since there’s only one configured')
-class MultiDatabaseTestCase(TestUtilsMixin, TransactionTestCase):
+class MultiDatabaseTestCase(TransactionTestCase):
multi_db = True
def setUp(self):
- super(MultiDatabaseTestCase, self).setUp()
-
self.t1 = Test.objects.create(name='test1')
self.t2 = Test.objects.create(name='test2')
self.db_alias2 = next(alias for alias in settings.DATABASES
@@ -26,6 +23,10 @@ class MultiDatabaseTestCase(TestUtilsMixin, TransactionTestCase):
connection2 = connections[self.db_alias2]
self.is_sqlite2 = connection2.vendor == 'sqlite'
self.is_mysql2 = connection2.vendor == 'mysql'
+ if connection2.vendor in ('mysql', 'postgresql'):
+ # We need to reopen the connection or Django
+ # will execute an extra SQL request below.
+ connection2.cursor()
def test_read(self):
with self.assertNumQueries(1):