From b67f2ac8e6f8cdef237590ffb2c85fc30454ba75 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Thu, 6 Jun 2013 14:27:00 +0200 Subject: [PATCH] Fixed #20502 (again) -- More i18n cache flush in tests Thanks Timo Graham for noticing the failures. --- django/contrib/humanize/tests.py | 4 +++- tests/forms_tests/tests/test_regressions.py | 3 ++- tests/template_tests/tests.py | 11 +++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/django/contrib/humanize/tests.py b/django/contrib/humanize/tests.py index 5c39c79ac3..54a60f8fd6 100644 --- a/django/contrib/humanize/tests.py +++ b/django/contrib/humanize/tests.py @@ -19,6 +19,8 @@ from django.utils.translation import ugettext as _ from django.utils import tzinfo from django.utils.unittest import skipIf +from i18n import TransRealMixin + # Mock out datetime in some tests so they don't fail occasionally when they # run too slow. Use a fixed datetime for datetime.now(). DST change in @@ -36,7 +38,7 @@ class MockDateTime(datetime.datetime): return now.replace(tzinfo=tz) + tz.utcoffset(now) -class HumanizeTests(TestCase): +class HumanizeTests(TransRealMixin, TestCase): def humanize_tester(self, test_list, result_list, method): for test_content, result in zip(test_list, result_list): diff --git a/tests/forms_tests/tests/test_regressions.py b/tests/forms_tests/tests/test_regressions.py index 74509a0f1a..ea138d32d5 100644 --- a/tests/forms_tests/tests/test_regressions.py +++ b/tests/forms_tests/tests/test_regressions.py @@ -8,9 +8,10 @@ from django.test import TestCase from django.utils.translation import ugettext_lazy, override from forms_tests.models import Cheese +from i18n import TransRealMixin -class FormsRegressionsTestCase(TestCase): +class FormsRegressionsTestCase(TransRealMixin, TestCase): def test_class(self): # Tests to prevent against recurrences of earlier bugs. extra_attrs = {'class': 'special'} diff --git a/tests/template_tests/tests.py b/tests/template_tests/tests.py index 15668e00c0..206c648398 100644 --- a/tests/template_tests/tests.py +++ b/tests/template_tests/tests.py @@ -36,6 +36,7 @@ from django.utils.safestring import mark_safe from django.utils import six from django.utils.tzinfo import LocalTimezone +from i18n import TransRealMixin try: from .loaders import RenderToStringTest, EggLoaderTest @@ -154,8 +155,8 @@ class UTF8Class: def __str__(self): return 'ŠĐĆŽćžšđ' -@override_settings(MEDIA_URL="/media/", STATIC_URL="/static/") -class Templates(TestCase): + +class TemplateLoaderTests(TestCase): def test_loaders_security(self): ad_loader = app_directories.Loader() @@ -347,6 +348,9 @@ class Templates(TestCase): loader.template_source_loaders = old_loaders settings.TEMPLATE_DEBUG = old_td + +class TemplateRegressionTests(TestCase): + def test_token_smart_split(self): # Regression test for #7027 token = template.Token(template.TOKEN_BLOCK, 'sometag _("Page not found") value|yesno:_("yes,no")') @@ -453,6 +457,9 @@ class Templates(TestCase): with self.assertRaises(urlresolvers.NoReverseMatch): t.render(Context({})) + +@override_settings(MEDIA_URL="/media/", STATIC_URL="/static/") +class TemplateTests(TransRealMixin, TestCase): def test_templates(self): template_tests = self.get_template_tests() filter_tests = filters.get_filter_tests()