summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThomas Chaumeny <thomas.chaumeny@polyconseil.fr>2014-08-28 22:26:37 +0200
committerSimon Charette <charette.s@gmail.com>2014-08-28 19:18:34 -0400
commitefcbf3e095dce3491eb52774978afe3f7bbdf217 (patch)
treed1a6a332f9840c9d33807e4b2687c9ccc8ac2f5f /tests
parent569e0a299ddf484a694d26b283214d1e55f7283e (diff)
Fixed #23381 -- Context manager restored state should be determined in __enter__
Diffstat (limited to 'tests')
-rw-r--r--tests/i18n/tests.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py
index 3ffcb08d8b..64e6eb5eed 100644
--- a/tests/i18n/tests.py
+++ b/tests/i18n/tests.py
@@ -74,7 +74,6 @@ class TranslationTests(TestCase):
deactivate()
def test_override_decorator(self):
- activate('de')
@translation.override('pl')
def func_pl():
@@ -85,6 +84,7 @@ class TranslationTests(TestCase):
self.assertEqual(get_language(), settings.LANGUAGE_CODE)
try:
+ activate('de')
func_pl()
self.assertEqual(get_language(), 'de')
func_none()
@@ -92,6 +92,24 @@ class TranslationTests(TestCase):
finally:
deactivate()
+ def test_override_exit(self):
+ """
+ Test that the language restored is the one used when the function was
+ called, not the one used when the decorator was initialized. refs #23381
+ """
+ activate('fr')
+ @translation.override('pl')
+ def func_pl():
+ pass
+ deactivate()
+
+ try:
+ activate('en')
+ func_pl()
+ self.assertEqual(get_language(), 'en')
+ finally:
+ deactivate()
+
def test_lazy_objects(self):
"""
Format string interpolation should work with *_lazy objects.