From 6148dda72f47e40754fc2eb75d86274fb68f2d41 Mon Sep 17 00:00:00 2001 From: Jirka Vejrazka Date: Wed, 4 Apr 2018 20:03:16 +0200 Subject: Fixed #29288 -- Made {% widthratio %} assign to as var if an exception occurs. --- tests/template_tests/syntax_tests/test_width_ratio.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests') 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, '--') -- cgit v1.3