summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2011-05-06 13:29:32 +0000
committerJannis Leidel <jannis@leidel.info>2011-05-06 13:29:32 +0000
commit71ec87fed83c0fb23f131d11f30031eeaa79ed77 (patch)
treec03b7ca9120d8f59fd1a788e940cca976b75f107 /tests
parent0dc6420b3ebddd7bc2a0059b225d54ac19d4d901 (diff)
Added django.utils.translation.override context manager to easily activate and deactivate a language for a code block.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16166 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/i18n/tests.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py
index 2a7f0c2841..8a8e4dc430 100644
--- a/tests/regressiontests/i18n/tests.py
+++ b/tests/regressiontests/i18n/tests.py
@@ -8,6 +8,7 @@ from threading import local
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, iter_format_modules, get_format_modules)
from django.utils.importlib import import_module
@@ -28,6 +29,13 @@ from test_warnings import DeprecationWarningTests
class TranslationTests(TestCase):
+ def test_override(self):
+ activate('de')
+ with translation.override('pl'):
+ self.assertEqual(get_language(), 'pl')
+ self.assertEqual(get_language(), 'de')
+ deactivate()
+
def test_lazy_objects(self):
"""
Format string interpolation should work with *_lazy objects.