1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #27539 -- Made TransactionTestCase._pre_setup() clear the queries_log so it's less likely to overflow.

TransactionTestCase.assertNumQueries() fails in an overflow situation.
This commit is contained in:
reficul31
2017-02-28 06:30:09 +05:30
committed by Tim Graham
parent 6f44f714c9
commit 92e286498a
2 changed files with 22 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
from unittest import mock
from django.test import TransactionTestCase
from django.db import connections
from django.test import TestCase, TransactionTestCase, override_settings
class TestSerializedRollbackInhibitsPostMigrate(TransactionTestCase):
@@ -28,3 +29,18 @@ class TestSerializedRollbackInhibitsPostMigrate(TransactionTestCase):
reset_sequences=False, inhibit_post_migrate=True,
database='default', verbosity=0,
)
@override_settings(DEBUG=True) # Enable query logging for test_queries_cleared
class TransactionTestCaseMultiDbTests(TestCase):
available_apps = []
multi_db = True
def test_queries_cleared(self):
"""
TransactionTestCase._pre_setup() clears the connections' queries_log
so that it's less likely to overflow. An overflow causes
assertNumQueries() to fail.
"""
for alias in connections:
self.assertEqual(len(connections[alias].queries_log), 0, 'Failed for alias %s' % alias)