summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRamiro Morales <cramm0@gmail.com>2010-10-10 01:57:56 +0000
committerRamiro Morales <cramm0@gmail.com>2010-10-10 01:57:56 +0000
commitd084439c415e2037a1d13b217b044fd1bf3b39cb (patch)
treef65710c9f6774cb8dc893f046b7d68926a60c46c /tests
parent05d438bdd94743c0c70a2d33b4f953d660ba131d (diff)
Fixed #12650 -- Don't generate invalid XHTML in the admin, databrowse apps when
the i18n context processor is active. Thanks to Rob Hudson for the report and fix suggestion. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14104 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/admin_views/tests.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
index 725369a5b1..c530839f5d 100644
--- a/tests/regressiontests/admin_views/tests.py
+++ b/tests/regressiontests/admin_views/tests.py
@@ -18,6 +18,7 @@ from django.utils.cache import get_max_age
from django.utils.encoding import iri_to_uri
from django.utils.html import escape
from django.utils.translation import get_date_formats, activate, deactivate
+import django.template.context
# local test models
from models import Article, BarAccount, CustomArticle, EmptyModel, \
@@ -2254,3 +2255,32 @@ try:
except ImportError:
pass
+
+class ValidXHTMLTests(TestCase):
+ fixtures = ['admin-views-users.xml']
+ urlbit = 'admin'
+
+ def setUp(self):
+ self._context_processors = None
+ self._use_i18n, settings.USE_I18N = settings.USE_I18N, False
+ if 'django.core.context_processors.i18n' in settings.TEMPLATE_CONTEXT_PROCESSORS:
+ self._context_processors = settings.TEMPLATE_CONTEXT_PROCESSORS
+ cp = list(settings.TEMPLATE_CONTEXT_PROCESSORS)
+ cp.remove('django.core.context_processors.i18n')
+ settings.TEMPLATE_CONTEXT_PROCESSORS = tuple(cp)
+ # Force re-evaluation of the contex processor list
+ django.template.context._standard_context_processors = None
+ self.client.login(username='super', password='secret')
+
+ def tearDown(self):
+ self.client.logout()
+ if self._context_processors is not None:
+ settings.TEMPLATE_CONTEXT_PROCESSORS = self._context_processors
+ # Force re-evaluation of the contex processor list
+ django.template.context._standard_context_processors = None
+ settings.USE_I18N = self._use_i18n
+
+ def testLangNamePresent(self):
+ response = self.client.get('/test_admin/%s/admin_views/' % self.urlbit)
+ self.failIf(' lang=""' in response.content)
+ self.failIf(' xml:lang=""' in response.content)