summaryrefslogtreecommitdiff
path: root/tests/regressiontests
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2010-09-27 15:25:08 +0000
committerJannis Leidel <jannis@leidel.info>2010-09-27 15:25:08 +0000
commit534792d05591eb2d19dc48ee89dcd2d9b5d461c0 (patch)
treef5e2fcd19541726fe51fc7c9507300733053b1da /tests/regressiontests
parent9c402f0ecc3751a746cc0aeaa24b7b8320af70f7 (diff)
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.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13898 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests')
-rw-r--r--tests/regressiontests/i18n/other/__init__.py0
-rw-r--r--tests/regressiontests/i18n/other/locale/__init__.py0
-rw-r--r--tests/regressiontests/i18n/other/locale/de/__init__.py0
-rw-r--r--tests/regressiontests/i18n/other/locale/de/formats.py0
-rw-r--r--tests/regressiontests/i18n/tests.py20
5 files changed, 19 insertions, 1 deletions
diff --git a/tests/regressiontests/i18n/other/__init__.py b/tests/regressiontests/i18n/other/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/regressiontests/i18n/other/__init__.py
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
--- /dev/null
+++ b/tests/regressiontests/i18n/other/locale/__init__.py
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
--- /dev/null
+++ b/tests/regressiontests/i18n/other/locale/de/__init__.py
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
--- /dev/null
+++ b/tests/regressiontests/i18n/other/locale/de/formats.py
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):