Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 Morales authored February 03, 2011
4  django/utils/formats.py
@@ -36,12 +36,12 @@ def iter_format_modules(lang):
36 36
 
37 37
 def get_format_modules(reverse=False):
38 38
     """
39  
-    Returns an iterator over the format modules found
  39
+    Returns a list of the format modules found
40 40
     """
41 41
     lang = get_language()
42 42
     modules = _format_modules_cache.setdefault(lang, list(iter_format_modules(lang)))
43 43
     if reverse:
44  
-        modules.reverse()
  44
+        return list(reversed(modules))
45 45
     return modules
46 46
 
47 47
 def get_format(format_type, lang=None, use_l10n=None):
15  tests/regressiontests/i18n/tests.py
@@ -9,7 +9,7 @@
9 9
 from django.conf import settings
10 10
 from django.template import Template, Context
11 11
 from django.utils.formats import (get_format, date_format, time_format,
12  
-    localize, localize_input, iter_format_modules)
  12
+    localize, localize_input, iter_format_modules, get_format_modules)
13 13
 from django.utils.importlib import import_module
14 14
 from django.utils.numberformat import format as nformat
15 15
 from django.utils.safestring import mark_safe, SafeString, SafeUnicode
@@ -495,6 +495,19 @@ def test_iter_format_modules_stability(self):
495 495
         finally:
496 496
             settings.USE_L10N = old_l10n
497 497
 
  498
+    def test_get_format_modules_stability(self):
  499
+        activate('de')
  500
+        old_format_module_path = settings.FORMAT_MODULE_PATH
  501
+        settings.FORMAT_MODULE_PATH = 'regressiontests.i18n.other.locale'
  502
+        try:
  503
+            settings.USE_L10N = True
  504
+            old = "%r" % get_format_modules(reverse=True)
  505
+            new = "%r" % get_format_modules(reverse=True) # second try
  506
+            self.assertEqual(new, old, 'Value returned by get_formats_modules() must be preserved between calls.')
  507
+        finally:
  508
+            settings.FORMAT_MODULE_PATH = old_format_module_path
  509
+            deactivate()
  510
+
498 511
     def test_localize_templatetag_and_filter(self):
499 512
         """
500 513
         Tests the {% localize %} templatetag

0 notes on commit 987fd51

Please sign in to comment.
Something went wrong with that request. Please try again.