mirror of
https://github.com/django/django.git
synced 2025-07-04 09:49:12 +00:00
[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')
|
activate('de-at')
|
||||||
old_USE_L10N = settings.USE_L10N
|
old_USE_L10N = settings.USE_L10N
|
||||||
settings.USE_L10N = True
|
try:
|
||||||
w.is_localized = True
|
settings.USE_L10N = True
|
||||||
self.assertEqual(
|
w.is_localized = True
|
||||||
conditional_escape(w.render('test', datetime(2007, 12, 1, 9, 30))),
|
self.assertEqual(
|
||||||
'<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>',
|
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
|
finally:
|
||||||
|
deactivate()
|
||||||
|
settings.USE_L10N = old_USE_L10N
|
||||||
|
|
||||||
|
|
||||||
class AdminFileWidgetTest(DjangoTestCase):
|
class AdminFileWidgetTest(DjangoTestCase):
|
||||||
|
@ -233,10 +233,8 @@ class FormattingTests(TestCase):
|
|||||||
deactivate()
|
deactivate()
|
||||||
|
|
||||||
def test_l10n_enabled(self):
|
def test_l10n_enabled(self):
|
||||||
"""
|
|
||||||
Catalan locale
|
|
||||||
"""
|
|
||||||
settings.USE_L10N = True
|
settings.USE_L10N = True
|
||||||
|
# Catalan locale
|
||||||
activate('ca')
|
activate('ca')
|
||||||
try:
|
try:
|
||||||
self.assertEqual('j \de F \de Y', get_format('DATE_FORMAT'))
|
self.assertEqual('j \de F \de Y', get_format('DATE_FORMAT'))
|
||||||
@ -324,8 +322,6 @@ class FormattingTests(TestCase):
|
|||||||
deactivate()
|
deactivate()
|
||||||
|
|
||||||
# English locale
|
# English locale
|
||||||
|
|
||||||
settings.USE_L10N = True
|
|
||||||
activate('en')
|
activate('en')
|
||||||
try:
|
try:
|
||||||
self.assertEqual('N j, Y', get_format('DATE_FORMAT'))
|
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
|
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.
|
a stable and correct order in presence of both base ll and ll_CC formats.
|
||||||
"""
|
"""
|
||||||
try:
|
settings.USE_L10N = True
|
||||||
old_l10n, settings.USE_L10N = settings.USE_L10N, True
|
en_format_mod = import_module('django.conf.locale.en.formats')
|
||||||
en_format_mod = import_module('django.conf.locale.en.formats')
|
en_gb_format_mod = import_module('django.conf.locale.en_GB.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])
|
||||||
self.assertEqual(list(iter_format_modules('en-gb')), [en_gb_format_mod, en_format_mod])
|
|
||||||
finally:
|
|
||||||
settings.USE_L10N = old_l10n
|
|
||||||
|
|
||||||
def test_get_format_modules_stability(self):
|
def test_get_format_modules_stability(self):
|
||||||
activate('de')
|
activate('de')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user