Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[1.2.X] Fixed a broken test introduced in [14786].

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14806 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 70383ccf68934d3f520cae0938d86c373e625513 1 parent cc48f66
@alex alex authored
View
14 tests/modeltests/raw_query/tests.py
@@ -1,5 +1,7 @@
from datetime import date
+from django.conf import settings
+from django.db import connection
from django.db.models.sql.query import InvalidQuery
from django.test import TestCase
@@ -53,6 +55,16 @@ def assertAnnotations(self, results, expected_annotations):
self.assertTrue(hasattr(result, annotation))
self.assertEqual(getattr(result, annotation), value)
+ def assert_num_queries(self, n, func, *args, **kwargs):
+ old_DEBUG = settings.DEBUG
+ settings.DEBUG = True
+ starting_queries = len(connection.queries)
+ try:
+ func(*args, **kwargs)
+ finally:
+ settings.DEBUG = old_DEBUG
+ self.assertEqual(starting_queries + n, len(connection.queries))
+
def testSimpleRawQuery(self):
"""
Basic test of raw query with a simple database query
@@ -219,6 +231,6 @@ def test_inheritance(self):
)
def test_query_count(self):
- self.assertNumQueries(1,
+ self.assert_num_queries(1,
list, Author.objects.raw("SELECT * FROM raw_query_author")
)
View
1  tests/regressiontests/defer_regress/tests.py
@@ -21,7 +21,6 @@ def assert_num_queries(self, n, func, *args, **kwargs):
settings.DEBUG = old_DEBUG
self.assertEqual(starting_queries + n, len(connection.queries))
-
def test_basic(self):
# Deferred fields should really be deferred and not accidentally use
# the field's default value just because they aren't passed to __init__

0 comments on commit 70383cc

Please sign in to comment.
Something went wrong with that request. Please try again.