[1.2.X] Modified a few tests methods to make sure no leaks of activated locale or USE_L10N setting value happen between tests.
Backport of [15411] from trunk git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15412 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
6ba0f324e4
commit
05232a2604
|
@ -209,14 +209,16 @@ class AdminSplitDateTimeWidgetTest(TestCase):
|
|||
|
||||
activate('de-at')
|
||||
old_USE_L10N = settings.USE_L10N
|
||||
settings.USE_L10N = True
|
||||
w.is_localized = True
|
||||
self.assertEqual(
|
||||
conditional_escape(w.render('test', datetime(2007, 12, 1, 9, 30))),
|
||||
'<p class="datetime">Datum: <input value="01.12.2007" type="text" class="vDateField" name="test_0" size="10" /><br />Zeit: <input value="09:30:00" type="text" class="vTimeField" name="test_1" size="8" /></p>',
|
||||
)
|
||||
deactivate()
|
||||
settings.USE_L10N = old_USE_L10N
|
||||
try:
|
||||
settings.USE_L10N = True
|
||||
w.is_localized = True
|
||||
self.assertEqual(
|
||||
conditional_escape(w.render('test', datetime(2007, 12, 1, 9, 30))),
|
||||
'<p class="datetime">Datum: <input value="01.12.2007" type="text" class="vDateField" name="test_0" size="10" /><br />Zeit: <input value="09:30:00" type="text" class="vTimeField" name="test_1" size="8" /></p>',
|
||||
)
|
||||
finally:
|
||||
deactivate()
|
||||
settings.USE_L10N = old_USE_L10N
|
||||
|
||||
|
||||
class AdminFileWidgetTest(DjangoTestCase):
|
||||
|
|
|
@ -233,10 +233,8 @@ class FormattingTests(TestCase):
|
|||
deactivate()
|
||||
|
||||
def test_l10n_enabled(self):
|
||||
"""
|
||||
Catalan locale
|
||||
"""
|
||||
settings.USE_L10N = True
|
||||
# Catalan locale
|
||||
activate('ca')
|
||||
try:
|
||||
self.assertEqual('j \de F \de Y', get_format('DATE_FORMAT'))
|
||||
|
@ -324,8 +322,6 @@ class FormattingTests(TestCase):
|
|||
deactivate()
|
||||
|
||||
# English locale
|
||||
|
||||
settings.USE_L10N = True
|
||||
activate('en')
|
||||
try:
|
||||
self.assertEqual('N j, Y', get_format('DATE_FORMAT'))
|
||||
|
@ -459,13 +455,10 @@ class FormattingTests(TestCase):
|
|||
Tests the iter_format_modules function always yields format modules in
|
||||
a stable and correct order in presence of both base ll and ll_CC formats.
|
||||
"""
|
||||
try:
|
||||
old_l10n, settings.USE_L10N = settings.USE_L10N, True
|
||||
en_format_mod = import_module('django.conf.locale.en.formats')
|
||||
en_gb_format_mod = import_module('django.conf.locale.en_GB.formats')
|
||||
self.assertEqual(list(iter_format_modules('en-gb')), [en_gb_format_mod, en_format_mod])
|
||||
finally:
|
||||
settings.USE_L10N = old_l10n
|
||||
settings.USE_L10N = True
|
||||
en_format_mod = import_module('django.conf.locale.en.formats')
|
||||
en_gb_format_mod = import_module('django.conf.locale.en_GB.formats')
|
||||
self.assertEqual(list(iter_format_modules('en-gb')), [en_gb_format_mod, en_format_mod])
|
||||
|
||||
def test_get_format_modules_stability(self):
|
||||
activate('de')
|
||||
|
|
Loading…
Reference in New Issue