summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Brochhaus <mbrochh@gmail.com>2014-05-19 13:23:45 +0800
committerTim Graham <timograham@gmail.com>2014-05-21 07:35:47 -0400
commitbb0a9a070b9570c85bcb17346dae6513e4ba6e76 (patch)
tree17c9f8c4cd129536b5cc583d5da8b82967a58521 /tests
parentdfeef8e1472eadf7c3d350f6ee7328352e5953f0 (diff)
Fixed #20477: Allowed list of modules for FORMAT_MODULE_PATH
Previously the FORMAT_MODULE_PATH setting only accepted one string (dotted module path). A feature has been added to also allow a list of strings. This is useful when using several reusable third party apps that define new formats. We can now use them all and we can even override some of the formats by providing a project-wide format module.
Diffstat (limited to 'tests')
-rw-r--r--tests/i18n/other2/__init__.py0
-rw-r--r--tests/i18n/other2/locale/__init__.py0
-rw-r--r--tests/i18n/other2/locale/de/__init__.py0
-rw-r--r--tests/i18n/other2/locale/de/formats.py0
-rw-r--r--tests/i18n/tests.py24
5 files changed, 20 insertions, 4 deletions
diff --git a/tests/i18n/other2/__init__.py b/tests/i18n/other2/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/i18n/other2/__init__.py
diff --git a/tests/i18n/other2/locale/__init__.py b/tests/i18n/other2/locale/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/i18n/other2/locale/__init__.py
diff --git a/tests/i18n/other2/locale/de/__init__.py b/tests/i18n/other2/locale/de/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/i18n/other2/locale/de/__init__.py
diff --git a/tests/i18n/other2/locale/de/formats.py b/tests/i18n/other2/locale/de/formats.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/i18n/other2/locale/de/formats.py
diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py
index 8d0fc963af..d07c0d94a0 100644
--- a/tests/i18n/tests.py
+++ b/tests/i18n/tests.py
@@ -738,11 +738,27 @@ class FormattingTests(TestCase):
"""
Tests the iter_format_modules function.
"""
+ # Importing some format modules so that we can compare the returned
+ # modules with these expected modules
+ default_mod = import_module('django.conf.locale.de.formats')
+ test_mod = import_module('i18n.other.locale.de.formats')
+ test_mod2 = import_module('i18n.other2.locale.de.formats')
+
with translation.override('de-at', deactivate=True):
- de_format_mod = import_module('django.conf.locale.de.formats')
- self.assertEqual(list(iter_format_modules('de')), [de_format_mod])
- test_de_format_mod = import_module('i18n.other.locale.de.formats')
- self.assertEqual(list(iter_format_modules('de', 'i18n.other.locale')), [test_de_format_mod, de_format_mod])
+ # Should return the correct default module when no setting is set
+ self.assertEqual(list(iter_format_modules('de')), [default_mod])
+
+ # When the setting is a string, should return the given module and
+ # the default module
+ self.assertEqual(
+ list(iter_format_modules('de', 'i18n.other.locale')),
+ [test_mod, default_mod])
+
+ # When setting is a list of strings, should return the given
+ # modules and the default module
+ self.assertEqual(
+ list(iter_format_modules('de', ['i18n.other.locale', 'i18n.other2.locale'])),
+ [test_mod, test_mod2, default_mod])
def test_iter_format_modules_stability(self):
"""