diff --git a/tests/regressiontests/admin_widgets/tests.py b/tests/regressiontests/admin_widgets/tests.py
index 78e7ba42d9..442fb1ef80 100644
--- a/tests/regressiontests/admin_widgets/tests.py
+++ b/tests/regressiontests/admin_widgets/tests.py
@@ -210,14 +210,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))),
- '
Datum:
Zeit:
',
- )
- 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))),
+ 'Datum:
Zeit:
',
+ )
+ finally:
+ deactivate()
+ settings.USE_L10N = old_USE_L10N
class AdminFileWidgetTest(DjangoTestCase):
diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py
index d023462311..f3fda9ae23 100644
--- a/tests/regressiontests/i18n/tests.py
+++ b/tests/regressiontests/i18n/tests.py
@@ -253,10 +253,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'))
@@ -345,15 +343,15 @@ class FormattingTests(TestCase):
# Russian locale (with E as month)
activate('ru')
- self.assertEqual(
- u'\n\n',
- SelectDateWidget(years=range(2009, 2019)).render('mydate', datetime.date(2009, 12, 31))
- )
- deactivate()
+ try:
+ self.assertEqual(
+ u'\n\n',
+ SelectDateWidget(years=range(2009, 2019)).render('mydate', datetime.date(2009, 12, 31))
+ )
+ finally:
+ deactivate()
# English locale
-
- settings.USE_L10N = True
activate('en')
try:
self.assertEqual('N j, Y', get_format('DATE_FORMAT'))
@@ -487,13 +485,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')