From 534792d05591eb2d19dc48ee89dcd2d9b5d461c0 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 27 Sep 2010 15:25:08 +0000 Subject: Fixed #14290 -- Made format localization faster by caching the format modules. Thanks, Teemu Kurppa and Anssi Kääriäinen for the report and initial patches. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://code.djangoproject.com/svn/django/trunk@13898 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/i18n/other/__init__.py | 0 tests/regressiontests/i18n/other/locale/__init__.py | 0 .../regressiontests/i18n/other/locale/de/__init__.py | 0 .../regressiontests/i18n/other/locale/de/formats.py | 0 tests/regressiontests/i18n/tests.py | 20 +++++++++++++++++++- 5 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/regressiontests/i18n/other/__init__.py create mode 100644 tests/regressiontests/i18n/other/locale/__init__.py create mode 100644 tests/regressiontests/i18n/other/locale/de/__init__.py create mode 100644 tests/regressiontests/i18n/other/locale/de/formats.py (limited to 'tests') diff --git a/tests/regressiontests/i18n/other/__init__.py b/tests/regressiontests/i18n/other/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/regressiontests/i18n/other/locale/__init__.py b/tests/regressiontests/i18n/other/locale/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/regressiontests/i18n/other/locale/de/__init__.py b/tests/regressiontests/i18n/other/locale/de/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/regressiontests/i18n/other/locale/de/formats.py b/tests/regressiontests/i18n/other/locale/de/formats.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py index 7e2e9f8228..01f6aa0d3f 100644 --- a/tests/regressiontests/i18n/tests.py +++ b/tests/regressiontests/i18n/tests.py @@ -8,10 +8,11 @@ import pickle from django.conf import settings from django.template import Template, Context from django.test import TestCase -from django.utils.formats import get_format, date_format, time_format, localize, localize_input +from django.utils.formats import get_format, date_format, time_format, localize, localize_input, iter_format_modules from django.utils.numberformat import format as nformat from django.utils.safestring import mark_safe, SafeString, SafeUnicode from django.utils.translation import ugettext, ugettext_lazy, activate, deactivate, gettext_lazy, to_locale +from django.utils.importlib import import_module from forms import I18nForm, SelectDateForm, SelectDateWidget, CompanyForm @@ -423,6 +424,23 @@ class FormattingTests(TestCase): finally: deactivate() + def test_iter_format_modules(self): + """ + Tests the iter_format_modules function. + """ + activate('de-at') + old_format_module_path = settings.FORMAT_MODULE_PATH + try: + settings.USE_L10N = True + de_format_mod = import_module('django.conf.locale.de.formats') + self.assertEqual(list(iter_format_modules('de')), [de_format_mod]) + settings.FORMAT_MODULE_PATH = 'regressiontests.i18n.other.locale' + test_de_format_mod = import_module('regressiontests.i18n.other.locale.de.formats') + self.assertEqual(list(iter_format_modules('de')), [test_de_format_mod, de_format_mod]) + finally: + settings.FORMAT_MODULE_PATH = old_format_module_path + deactivate() + class MiscTests(TestCase): def test_parse_spec_http_header(self): -- cgit v1.3