Author: lukeplant
Date: 2010-12-18 13:35:46 -0600 (Sat, 18 Dec 2010)
New Revision: 14930
Modified:
django/branches/releases/1.2.X/tests/modeltests/model_inheritance/tests.py
django/branches/releases/1.2.X/tests/regressiontests/views/tests/defaults.py
Log:
[1.2.X] Fixed #14919 - test isolation issue with
model_inheritance.ModelInheritanceTests.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.
Modified:
django/branches/releases/1.2.X/tests/modeltests/model_inheritance/tests.py
===================================================================
--- django/branches/releases/1.2.X/tests/modeltests/model_inheritance/tests.py
2010-12-18 17:40:53 UTC (rev 14929)
+++ django/branches/releases/1.2.X/tests/modeltests/model_inheritance/tests.py
2010-12-18 19:35:46 UTC (rev 14930)
@@ -266,12 +266,16 @@
# select_related works with fields from the parent object as if they
# were a normal part of the model.
old_DEBUG = settings.DEBUG
- starting_queries = len(connection.queries)
- settings.DEBUG = True
+ try:
+ settings.DEBUG = True
+ starting_queries = len(connection.queries)
+ ItalianRestaurant.objects.all()[0].chef
+ self.assertEqual(len(connection.queries) - starting_queries, 2)
- ItalianRestaurant.objects.all()[0].chef
- self.assertEqual(len(connection.queries) - starting_queries, 2)
+ starting_queries = len(connection.queries)
+ ItalianRestaurant.objects.select_related("chef")[0].chef
+ self.assertEqual(len(connection.queries) - starting_queries, 1)
+ finally:
+ settings.DEBUG = old_DEBUG
- starting_queries = len(connection.queries)
- ItalianRestaurant.objects.select_related("chef")[0].chef
- self.assertEqual(len(connection.queries) - starting_queries, 1)
+
Modified:
django/branches/releases/1.2.X/tests/regressiontests/views/tests/defaults.py
===================================================================
---
django/branches/releases/1.2.X/tests/regressiontests/views/tests/defaults.py
2010-12-18 17:40:53 UTC (rev 14929)
+++
django/branches/releases/1.2.X/tests/regressiontests/views/tests/defaults.py
2010-12-18 19:35:46 UTC (rev 14930)
@@ -60,11 +60,16 @@
The 404 page should have the csrf_token available in the context
"""
# See ticket #14565
- for url in self.non_existing_urls:
- response = self.client.get(url)
- csrf_token = response.context['csrf_token']
- self.assertNotEqual(str(csrf_token), 'NOTPROVIDED')
- self.assertNotEqual(str(csrf_token), '')
+ old_DEBUG = settings.DEBUG
+ try:
+ settings.DEBUG = False # so we get real 404, not technical
+ for url in self.non_existing_urls:
+ response = self.client.get(url)
+ csrf_token = response.context['csrf_token']
+ self.assertNotEqual(str(csrf_token), 'NOTPROVIDED')
+ self.assertNotEqual(str(csrf_token), '')
+ finally:
+ settings.DEBUG = old_DEBUG
def test_server_error(self):
"The server_error view raises a 500 status"
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.