summaryrefslogtreecommitdiff
path: root/tests/template_tests/syntax_tests/test_cycle.py
diff options
context:
space:
mode:
authorMads Jensen <mje@inducks.org>2018-03-24 21:38:20 +0100
committerTim Graham <timograham@gmail.com>2018-03-24 19:56:46 -0400
commit4554f9a783665d64b59c35b53ae71178e56ac783 (patch)
tree4281fbf14ba20f51fcc846441ccf86f72fe56e5f /tests/template_tests/syntax_tests/test_cycle.py
parent623117d1f1d7866b7321f0e73a6c497bb3b3cb01 (diff)
Increased test coverage for various template tags.
Diffstat (limited to 'tests/template_tests/syntax_tests/test_cycle.py')
-rw-r--r--tests/template_tests/syntax_tests/test_cycle.py28
1 files changed, 19 insertions, 9 deletions
diff --git a/tests/template_tests/syntax_tests/test_cycle.py b/tests/template_tests/syntax_tests/test_cycle.py
index b5712b54bb..12bf66e117 100644
--- a/tests/template_tests/syntax_tests/test_cycle.py
+++ b/tests/template_tests/syntax_tests/test_cycle.py
@@ -8,22 +8,20 @@ class CycleTagTests(SimpleTestCase):
@setup({'cycle01': '{% cycle a %}'})
def test_cycle01(self):
- with self.assertRaises(TemplateSyntaxError):
+ msg = "No named cycles in template. 'a' is not defined"
+ with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.get_template('cycle01')
@setup({'cycle05': '{% cycle %}'})
def test_cycle05(self):
- with self.assertRaises(TemplateSyntaxError):
+ msg = "'cycle' tag requires at least two arguments"
+ with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.get_template('cycle05')
- @setup({'cycle06': '{% cycle a %}'})
- def test_cycle06(self):
- with self.assertRaises(TemplateSyntaxError):
- self.engine.get_template('cycle06')
-
@setup({'cycle07': '{% cycle a,b,c as foo %}{% cycle bar %}'})
def test_cycle07(self):
- with self.assertRaises(TemplateSyntaxError):
+ msg = "Could not parse the remainder: ',b,c' from 'a,b,c'"
+ with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.get_template('cycle07')
@setup({'cycle10': "{% cycle 'a' 'b' 'c' as abc %}{% cycle abc %}"})
@@ -69,7 +67,8 @@ class CycleTagTests(SimpleTestCase):
@setup({'cycle18': "{% cycle 'a' 'b' 'c' as foo invalid_flag %}"})
def test_cycle18(self):
- with self.assertRaises(TemplateSyntaxError):
+ msg = "Only 'silent' flag is allowed after cycle's name, not 'invalid_flag'."
+ with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.get_template('cycle18')
@setup({'cycle19': "{% cycle 'a' 'b' as silent %}{% cycle silent %}"})
@@ -167,3 +166,14 @@ class CycleTagTests(SimpleTestCase):
'values': [1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 9, 9]
})
self.assertEqual(output, 'bcabcabcccaa')
+
+ @setup({
+ 'undefined_cycle':
+ "{% cycle 'a' 'b' 'c' as cycler silent %}"
+ "{% for x in values %}"
+ "{% cycle undefined %}{{ cycler }}"
+ "{% endfor %}"
+ })
+ def test_cycle_undefined(self):
+ with self.assertRaisesMessage(TemplateSyntaxError, "Named cycle 'undefined' does not exist"):
+ self.engine.render_to_string('undefined_cycle')