Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed stability of data input/output L10N format modules priority ord…

…er. Thanks tonnzor for the report and fix.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15402 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 987fd511769a3e1342fe8678a0b183f2831adb60 1 parent a158873
@ramiro ramiro authored
Showing with 16 additions and 3 deletions.
  1. +2 −2 django/utils/formats.py
  2. +14 −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, lang=None, use_l10n=None):
View
15 tests/regressiontests/i18n/tests.py
@@ -9,7 +9,7 @@
from django.conf import settings
from django.template import Template, Context
from django.utils.formats import (get_format, date_format, time_format,
- localize, localize_input, iter_format_modules)
+ localize, localize_input, iter_format_modules, get_format_modules)
from django.utils.importlib import import_module
from django.utils.numberformat import format as nformat
from django.utils.safestring import mark_safe, SafeString, SafeUnicode
@@ -495,6 +495,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()
+
def test_localize_templatetag_and_filter(self):
"""
Tests the {% localize %} templatetag
Please sign in to comment.
Something went wrong with that request. Please try again.