From 5a4f0a4f7a234b69bc3772cf0adad61ee6ff701e Mon Sep 17 00:00:00 2001 From: Bertrand Bordage Date: Tue, 21 Oct 2014 23:49:26 +0200 Subject: [PATCH] Fixes tests for Django 1.7 & MySQL. --- cachalot/tests/write.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cachalot/tests/write.py b/cachalot/tests/write.py index 0c751d1..da97d2f 100644 --- a/cachalot/tests/write.py +++ b/cachalot/tests/write.py @@ -554,6 +554,11 @@ class DatabaseCommandTestCase(TransactionTestCase): call_command('flush', verbosity=0, interactive=False) + if django_version >= (1, 7) and connection.vendor == 'mysql': + # We need to reopen the connection or Django + # will execute an extra SQL request below. + connection.cursor() + with self.assertNumQueries(1): self.assertListEqual(list(Test.objects.all()), []) @@ -564,6 +569,11 @@ class DatabaseCommandTestCase(TransactionTestCase): call_command('loaddata', 'cachalot/tests/loaddata_fixture.json', verbosity=0, interactive=False) + if django_version >= (1, 7) and connection.vendor == 'mysql': + # We need to reopen the connection or Django + # will execute an extra SQL request below. + connection.cursor() + with self.assertNumQueries(1): self.assertListEqual([t.name for t in Test.objects.all()], ['test1', 'test2'])