Ticket #15129: 15129.1.diff

File 15129.1.diff, 2.1 KB (added by Ramiro Morales, 14 years ago)

tonnzor's patch wth tests integrated with our test suite. Implementation of fix simply chanegs get_format_modules docstring to say it doesn

  • django/utils/formats.py

    diff -r 030518391c49 django/utils/formats.py
    a b  
    3636
    3737def get_format_modules(reverse=False):
    3838    """
    39     Returns an iterator over the format modules found
     39    Returns a list of the format modules found
    4040    """
    4141    lang = get_language()
    4242    modules = _format_modules_cache.setdefault(lang, list(iter_format_modules(lang)))
    4343    if reverse:
    44         modules.reverse()
     44        return reversed(modules)
    4545    return modules
    4646
    4747def get_format(format_type, lang=None, use_l10n=None):
  • tests/regressiontests/i18n/tests.py

    diff -r 030518391c49 tests/regressiontests/i18n/tests.py
    a b  
    99from django.conf import settings
    1010from django.template import Template, Context
    1111from 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)
    1313from django.utils.importlib import import_module
    1414from django.utils.numberformat import format as nformat
    1515from django.utils.safestring import mark_safe, SafeString, SafeUnicode
     
    495495        finally:
    496496            settings.USE_L10N = old_l10n
    497497
     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
    498511    def test_localize_templatetag_and_filter(self):
    499512        """
    500513        Tests the {% localize %} templatetag
Back to Top