Author: ramiro Date: 2011-01-12 21:13:39 -0600 (Wed, 12 Jan 2011) New Revision: 15184
Modified: django/branches/releases/1.2.X/django/utils/formats.py django/branches/releases/1.2.X/tests/regressiontests/i18n/tests.py Log: [1.2.X] Fixed #15024 -- Ensure that choice of L10N format module used is stable given a stable setup of format modules in ll/ and ll_CC/ dirs. Thanks David Reynolds for the report and suggestions leading to the solution. Backport of [15183] from trunk. Modified: django/branches/releases/1.2.X/django/utils/formats.py =================================================================== --- django/branches/releases/1.2.X/django/utils/formats.py 2011-01-13 03:02:32 UTC (rev 15183) +++ django/branches/releases/1.2.X/django/utils/formats.py 2011-01-13 03:13:39 UTC (rev 15184) @@ -24,7 +24,9 @@ format_locations.append(settings.FORMAT_MODULE_PATH + '.%s') format_locations.reverse() locale = to_locale(lang) - locales = set((locale, locale.split('_')[0])) + locales = [locale] + if '_' in locale: + locales.append(locale.split('_')[0]) for location in format_locations: for loc in locales: try: Modified: django/branches/releases/1.2.X/tests/regressiontests/i18n/tests.py =================================================================== --- django/branches/releases/1.2.X/tests/regressiontests/i18n/tests.py 2011-01-13 03:02:32 UTC (rev 15183) +++ django/branches/releases/1.2.X/tests/regressiontests/i18n/tests.py 2011-01-13 03:13:39 UTC (rev 15184) @@ -452,7 +452,20 @@ settings.FORMAT_MODULE_PATH = old_format_module_path deactivate() + def test_iter_format_modules_stability(self): + """ + Tests the iter_format_modules function always yields format modules in + a stable and correct order in presence of both base ll and ll_CC formats. + """ + try: + old_l10n, settings.USE_L10N = settings.USE_L10N, True + en_format_mod = import_module('django.conf.locale.en.formats') + en_gb_format_mod = import_module('django.conf.locale.en_GB.formats') + self.assertEqual(list(iter_format_modules('en-gb')), [en_gb_format_mod, en_format_mod]) + finally: + settings.USE_L10N = old_l10n + class MiscTests(TestCase): def test_parse_spec_http_header(self): -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.