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

Fixed #14774 -- the test client and assertNumQueries didn't work well together. Thanks to Jonas Obrist for the initial patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15251 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Alex Gaynor
2011-01-20 04:47:47 +00:00
parent 53dac996ef
commit 8308ad4f05
6 changed files with 70 additions and 12 deletions

View File

@@ -6,8 +6,10 @@ from xml.dom.minidom import parseString, Node
from django.conf import settings
from django.core import mail
from django.core.management import call_command
from django.core.signals import request_started
from django.core.urlresolvers import clear_url_caches
from django.db import transaction, connection, connections, DEFAULT_DB_ALIAS
from django.db import (transaction, connection, connections, DEFAULT_DB_ALIAS,
reset_queries)
from django.http import QueryDict
from django.test import _doctest as doctest
from django.test.client import Client
@@ -220,10 +222,12 @@ class _AssertNumQueriesContext(object):
self.old_debug_cursor = self.connection.use_debug_cursor
self.connection.use_debug_cursor = True
self.starting_queries = len(self.connection.queries)
request_started.disconnect(reset_queries)
return self
def __exit__(self, exc_type, exc_value, traceback):
self.connection.use_debug_cursor = self.old_debug_cursor
request_started.connect(reset_queries)
if exc_type is not None:
return