summaryrefslogtreecommitdiff
path: root/tests/template_tests/syntax_tests
diff options
context:
space:
mode:
authorJirka Vejrazka <Jirka.Vejrazka@gmail.com>2018-04-04 20:03:16 +0200
committerTim Graham <timograham@gmail.com>2018-04-04 14:03:16 -0400
commit6148dda72f47e40754fc2eb75d86274fb68f2d41 (patch)
treead9ed9efe7475fde98481df7ab367b39eec5be2a /tests/template_tests/syntax_tests
parent9fd9f8bbb23407254aa0ba851dbcc8e7f696c3de (diff)
Fixed #29288 -- Made {% widthratio %} assign to as var if an exception occurs.
Diffstat (limited to 'tests/template_tests/syntax_tests')
-rw-r--r--tests/template_tests/syntax_tests/test_width_ratio.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/template_tests/syntax_tests/test_width_ratio.py b/tests/template_tests/syntax_tests/test_width_ratio.py
index bec7d93a4c..7db90a44e1 100644
--- a/tests/template_tests/syntax_tests/test_width_ratio.py
+++ b/tests/template_tests/syntax_tests/test_width_ratio.py
@@ -142,3 +142,13 @@ class WidthRatioTagTests(SimpleTestCase):
def test_widthratio21(self):
output = self.engine.render_to_string('widthratio21', {'a': float('inf'), 'b': 2})
self.assertEqual(output, '')
+
+ @setup({'t': '{% widthratio a b 100 as variable %}-{{ variable }}-'})
+ def test_zerodivisionerror_as_var(self):
+ output = self.engine.render_to_string('t', {'a': 0, 'b': 0})
+ self.assertEqual(output, '-0-')
+
+ @setup({'t': '{% widthratio a b c as variable %}-{{ variable }}-'})
+ def test_typeerror_as_var(self):
+ output = self.engine.render_to_string('t', {'a': 'a', 'c': 100, 'b': 100})
+ self.assertEqual(output, '--')