Ticket #15024: 15024.diff

File 15024.diff, 1.5 KB (added by Ramiro Morales, 14 years ago)
  • django/utils/formats.py

    diff --git a/django/utils/formats.py b/django/utils/formats.py
    a b  
    2424            format_locations.append(settings.FORMAT_MODULE_PATH + '.%s')
    2525            format_locations.reverse()
    2626        locale = to_locale(lang)
    27         locales = set((locale, locale.split('_')[0]))
     27        locales = [locale]
     28        if '_' in locale:
     29            locales.append(locale.split('_')[0])
    2830        for location in format_locations:
    2931            for loc in locales:
    3032                try:
  • tests/regressiontests/i18n/tests.py

    diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py
    a b  
    480480            settings.FORMAT_MODULE_PATH = old_format_module_path
    481481            deactivate()
    482482
     483    def test_iter_format_modules_stability(self):
     484        """
     485        Tests the iter_format_modules function always yields format modules in
     486        a stable and correct order in presence of both base ll and ll_CC formats.
     487        """
     488        try:
     489            old_l10n, settings.USE_L10N = settings.USE_L10N, True
     490            en_format_mod = import_module('django.conf.locale.en.formats')
     491            en_gb_format_mod = import_module('django.conf.locale.en_GB.formats')
     492            self.assertEqual(list(iter_format_modules('en-gb')), [en_gb_format_mod, en_format_mod])
     493        finally:
     494            settings.USE_L10N = old_l10n
     495
    483496    def test_localize_templatetag_and_filter(self):
    484497        """
    485498        Tests the {% localize %} templatetag
Back to Top