Commit 70383ccf authored by Alex Gaynor's avatar Alex Gaynor
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
parent cc48f66f
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
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 @@ class RawQueryTests(TestCase):
                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 @@ class RawQueryTests(TestCase):
        )

    def test_query_count(self):
        self.assertNumQueries(1,
        self.assert_num_queries(1,
            list, Author.objects.raw("SELECT * FROM raw_query_author")
        )
+0 −1
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ class DeferRegressionTest(TestCase):
            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__