Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.2.X] Fixed #14919 - test isolation issue with model_inheritance.Mo…

…delInheritanceTests.test_multiple_table and views.DefaultsTests.test_csrf_token_in_404

test_csrf_token_in_404 was assuming DEBUG = False, and test_multiple_table
was leaving DEBUG = True.  Both issues have been fixed.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14930 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 5a33ce25003b5c17b143003910408826a68ddf1b 1 parent 6c357cc
Luke Plant authored December 18, 2010
18  tests/modeltests/model_inheritance/tests.py
@@ -266,12 +266,16 @@ def test_multiple_table(self):
266 266
         # select_related works with fields from the parent object as if they
267 267
         # were a normal part of the model.
268 268
         old_DEBUG = settings.DEBUG
269  
-        starting_queries = len(connection.queries)
270  
-        settings.DEBUG = True
  269
+        try:
  270
+            settings.DEBUG = True
  271
+            starting_queries = len(connection.queries)
  272
+            ItalianRestaurant.objects.all()[0].chef
  273
+            self.assertEqual(len(connection.queries) - starting_queries, 2)
  274
+
  275
+            starting_queries = len(connection.queries)
  276
+            ItalianRestaurant.objects.select_related("chef")[0].chef
  277
+            self.assertEqual(len(connection.queries) - starting_queries, 1)
  278
+        finally:
  279
+            settings.DEBUG = old_DEBUG
271 280
 
272  
-        ItalianRestaurant.objects.all()[0].chef
273  
-        self.assertEqual(len(connection.queries) - starting_queries, 2)
274 281
 
275  
-        starting_queries = len(connection.queries)
276  
-        ItalianRestaurant.objects.select_related("chef")[0].chef
277  
-        self.assertEqual(len(connection.queries) - starting_queries, 1)
15  tests/regressiontests/views/tests/defaults.py
@@ -60,11 +60,16 @@ def test_csrf_token_in_404(self):
60 60
         The 404 page should have the csrf_token available in the context
61 61
         """
62 62
         # See ticket #14565
63  
-        for url in self.non_existing_urls:
64  
-            response = self.client.get(url)
65  
-            csrf_token = response.context['csrf_token']
66  
-            self.assertNotEqual(str(csrf_token), 'NOTPROVIDED')
67  
-            self.assertNotEqual(str(csrf_token), '')
  63
+        old_DEBUG = settings.DEBUG
  64
+        try:
  65
+            settings.DEBUG = False # so we get real 404, not technical
  66
+            for url in self.non_existing_urls:
  67
+                response = self.client.get(url)
  68
+                csrf_token = response.context['csrf_token']
  69
+                self.assertNotEqual(str(csrf_token), 'NOTPROVIDED')
  70
+                self.assertNotEqual(str(csrf_token), '')
  71
+        finally:
  72
+            settings.DEBUG = old_DEBUG
68 73
 
69 74
     def test_server_error(self):
70 75
         "The server_error view raises a 500 status"

0 notes on commit 5a33ce2

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