summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2015-06-12 13:51:28 +0100
committerTim Graham <timograham@gmail.com>2015-07-01 10:03:00 -0400
commit839edcebb39f55acf163266f1ce1f0dc537de95b (patch)
treeafca4d9d29d470d54673e87e8147f48a3d0c8d33 /tests
parentb35b43dff81d46e930ffa1e05eb50968b8557102 (diff)
Fixed #21695 -- Added asvar option to blocktrans.
Thanks Bojan Mihelac for the initial patch.
Diffstat (limited to 'tests')
-rw-r--r--tests/template_tests/syntax_tests/test_i18n.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/template_tests/syntax_tests/test_i18n.py b/tests/template_tests/syntax_tests/test_i18n.py
index e40144e347..68b5793a57 100644
--- a/tests/template_tests/syntax_tests/test_i18n.py
+++ b/tests/template_tests/syntax_tests/test_i18n.py
@@ -435,6 +435,35 @@ class I18nTagTests(SimpleTestCase):
'fr: French/français/francouzsky bidi=False; '
)
+ # blocktrans tag with asvar
+ @setup({'i18n39': '{% load i18n %}'
+ '{% blocktrans asvar page_not_found %}Page not found{% endblocktrans %}'
+ '>{{ page_not_found }}<'})
+ def test_i18n39(self):
+ with translation.override('de'):
+ output = self.engine.render_to_string('i18n39')
+ self.assertEqual(output, '>Seite nicht gefunden<')
+
+ @setup({'i18n40': '{% load i18n %}'
+ '{% trans "Page not found" as pg_404 %}'
+ '{% blocktrans with page_not_found=pg_404 asvar output %}'
+ 'Error: {{ page_not_found }}'
+ '{% endblocktrans %}'})
+ def test_i18n40(self):
+ output = self.engine.render_to_string('i18n40')
+ self.assertEqual(output, '')
+
+ @setup({'i18n41': '{% load i18n %}'
+ '{% trans "Page not found" as pg_404 %}'
+ '{% blocktrans with page_not_found=pg_404 asvar output %}'
+ 'Error: {{ page_not_found }}'
+ '{% endblocktrans %}'
+ '>{{ output }}<'})
+ def test_i18n41(self):
+ with translation.override('de'):
+ output = self.engine.render_to_string('i18n41')
+ self.assertEqual(output, '>Error: Seite nicht gefunden<')
+
@setup({'template': '{% load i18n %}{% trans %}A}'})
def test_syntax_error_no_arguments(self):
msg = "'trans' takes at least one argument"
@@ -453,6 +482,12 @@ class I18nTagTests(SimpleTestCase):
with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.render_to_string('template')
+ @setup({'template': '{% load i18n %}{% blocktrans asvar %}Yes{% endblocktrans %}'})
+ def test_blocktrans_syntax_error_missing_assignment(self):
+ msg = "No argument provided to the 'blocktrans' tag for the asvar option."
+ with self.assertRaisesMessage(TemplateSyntaxError, msg):
+ self.engine.render_to_string('template')
+
@setup({'template': '{% load i18n %}{% trans "Yes" as var context %}'})
def test_syntax_error_missing_context(self):
msg = "No argument provided to the 'trans' tag for the context option."