Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[1.2.X] Modified a few tests methods to make sure no leaks of activat…

…ed 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
  • Loading branch information...
commit 05232a2604725400358c012fa17ac705c875a9f4 1 parent 6ba0f32
@ramiro ramiro authored
View
18 tests/regressiontests/admin_widgets/tests.py
@@ -209,14 +209,16 @@ def test_localization(self):
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):
View
17 tests/regressiontests/i18n/tests.py
@@ -233,10 +233,8 @@ def test_l10n_disabled(self):
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 @@ def test_l10n_enabled(self):
deactivate()
# English locale
-
- settings.USE_L10N = True
activate('en')
try:
self.assertEqual('N j, Y', get_format('DATE_FORMAT'))
@@ -459,13 +455,10 @@ def test_iter_format_modules_stability(self):
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')
Please sign in to comment.
Something went wrong with that request. Please try again.