Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.2.X] Fixed #15129 -- Fixed stability of data input/output L10N for…

…mat modules priority order. Thanks tonnzor for the report and fix.

Backport of [15402] from trunk

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15403 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 5f2f0113db4489de4b2260bf3365b514418ad0b8 1 parent f6606da
@ramiro ramiro authored
Showing with 17 additions and 3 deletions.
  1. +2 −2 django/utils/formats.py
  2. +15 −1 tests/regressiontests/i18n/tests.py
View
4 django/utils/formats.py
@@ -36,12 +36,12 @@ def iter_format_modules(lang):
def get_format_modules(reverse=False):
"""
- Returns an iterator over the format modules found
+ Returns a list of the format modules found
"""
lang = get_language()
modules = _format_modules_cache.setdefault(lang, list(iter_format_modules(lang)))
if reverse:
- modules.reverse()
+ return list(reversed(modules))
return modules
def get_format(format_type):
View
16 tests/regressiontests/i18n/tests.py
@@ -8,7 +8,8 @@
from django.conf import settings
from django.template import Template, Context
from django.test import TestCase
-from django.utils.formats import get_format, date_format, time_format, localize, localize_input, iter_format_modules
+from django.utils.formats import (get_format, date_format, time_format,
+ localize, localize_input, iter_format_modules, get_format_modules)
from django.utils.numberformat import format as nformat
from django.utils.safestring import mark_safe, SafeString, SafeUnicode
from django.utils.translation import (ugettext, ugettext_lazy, activate,
@@ -466,6 +467,19 @@ def test_iter_format_modules_stability(self):
finally:
settings.USE_L10N = old_l10n
+ def test_get_format_modules_stability(self):
+ activate('de')
+ old_format_module_path = settings.FORMAT_MODULE_PATH
+ settings.FORMAT_MODULE_PATH = 'regressiontests.i18n.other.locale'
+ try:
+ settings.USE_L10N = True
+ old = "%r" % get_format_modules(reverse=True)
+ new = "%r" % get_format_modules(reverse=True) # second try
+ self.assertEqual(new, old, 'Value returned by get_formats_modules() must be preserved between calls.')
+ finally:
+ settings.FORMAT_MODULE_PATH = old_format_module_path
+ deactivate()
+
class MiscTests(TestCase):
Please sign in to comment.
Something went wrong with that request. Please try again.