diff -r 030518391c49 django/utils/formats.py
a
|
b
|
|
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): |
diff -r 030518391c49 tests/regressiontests/i18n/tests.py
a
|
b
|
|
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 | 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 |