diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2010-10-29 16:48:58 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2010-10-29 16:48:58 +0000 |
| commit | ccc49029b8d84cf3eaaa3593df6370329f7b14e1 (patch) | |
| tree | 3e88f1a774a557cae46a7095073ccf6e05e7fff8 /tests/regressiontests | |
| parent | 269e921756371bee6d35a967bc2ffe84d1ae39eb (diff) | |
Fixed #14181 -- Added a template tag and filters to allow localization to be disabled in a template. Thanks to Benjamin Wohlwend for the work on the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14395 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests')
| -rw-r--r-- | tests/regressiontests/i18n/tests.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py index 4aa52b6b55..bac77b0dbc 100644 --- a/tests/regressiontests/i18n/tests.py +++ b/tests/regressiontests/i18n/tests.py @@ -453,6 +453,33 @@ class FormattingTests(TestCase): settings.FORMAT_MODULE_PATH = old_format_module_path deactivate() + def test_localize_templatetag_and_filter(self): + """ + Tests the {% localize %} templatetag + """ + context = Context({'value': 3.14 }) + template1 = Template("{% load l10n %}{% localize %}{{ value }}{% endlocalize %};{% localize on %}{{ value }}{% endlocalize %}") + template2 = Template("{% load l10n %}{{ value }};{% localize off %}{{ value }};{% endlocalize %}{{ value }}") + template3 = Template('{% load l10n %}{{ value }};{{ value|unlocalize }}') + template4 = Template('{% load l10n %}{{ value }};{{ value|localize }}') + output1 = '3,14;3,14' + output2 = '3,14;3.14;3,14' + output3 = '3,14;3.14' + output4 = '3.14;3,14' + old_localize = settings.USE_L10N + try: + activate('de') + settings.USE_L10N = False + self.assertEqual(template1.render(context), output1) + self.assertEqual(template4.render(context), output4) + settings.USE_L10N = True + self.assertEqual(template1.render(context), output1) + self.assertEqual(template2.render(context), output2) + self.assertEqual(template3.render(context), output3) + finally: + deactivate() + settings.USE_L10N = old_localize + class MiscTests(TestCase): def test_parse_spec_http_header(self): |
