diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-12-07 09:43:10 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-12-28 16:23:01 +0100 |
| commit | 92a2d049a253fb499db88efb6cf6c9209f6f251c (patch) | |
| tree | bd3c913883b36f918f3c8ae7af942a8c8f50a23f /tests/template_tests/syntax_tests/test_cycle.py | |
| parent | b34b8a12b7f657f379c9e0e5ee7688bf36e242d2 (diff) | |
Isolated template tests from Django settings.
Diffstat (limited to 'tests/template_tests/syntax_tests/test_cycle.py')
| -rw-r--r-- | tests/template_tests/syntax_tests/test_cycle.py | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/tests/template_tests/syntax_tests/test_cycle.py b/tests/template_tests/syntax_tests/test_cycle.py index 0c18ccba90..8a47ff8879 100644 --- a/tests/template_tests/syntax_tests/test_cycle.py +++ b/tests/template_tests/syntax_tests/test_cycle.py @@ -1,11 +1,10 @@ import warnings -from django.template.base import TemplateSyntaxError -from django.template.loader import get_template +from django.template import TemplateSyntaxError from django.test import SimpleTestCase from django.utils.deprecation import RemovedInDjango20Warning -from ..utils import render, setup +from ..utils import setup class CycleTagTests(SimpleTestCase): @@ -13,119 +12,119 @@ class CycleTagTests(SimpleTestCase): @setup({'cycle01': '{% cycle a %}'}) def test_cycle01(self): with self.assertRaises(TemplateSyntaxError): - get_template('cycle01') + self.engine.get_template('cycle01') @setup({'cycle02': '{% cycle a,b,c as abc %}{% cycle abc %}'}) def test_cycle02(self): - output = render('cycle02') + output = self.engine.render_to_string('cycle02') self.assertEqual(output, 'ab') @setup({'cycle03': '{% cycle a,b,c as abc %}{% cycle abc %}{% cycle abc %}'}) def test_cycle03(self): - output = render('cycle03') + output = self.engine.render_to_string('cycle03') self.assertEqual(output, 'abc') @setup({'cycle04': '{% cycle a,b,c as abc %}{% cycle abc %}{% cycle abc %}{% cycle abc %}'}) def test_cycle04(self): - output = render('cycle04') + output = self.engine.render_to_string('cycle04') self.assertEqual(output, 'abca') @setup({'cycle05': '{% cycle %}'}) def test_cycle05(self): with self.assertRaises(TemplateSyntaxError): - get_template('cycle05') + self.engine.get_template('cycle05') @setup({'cycle06': '{% cycle a %}'}) def test_cycle06(self): with self.assertRaises(TemplateSyntaxError): - get_template('cycle06') + self.engine.get_template('cycle06') @setup({'cycle07': '{% cycle a,b,c as foo %}{% cycle bar %}'}) def test_cycle07(self): with self.assertRaises(TemplateSyntaxError): - get_template('cycle07') + self.engine.get_template('cycle07') @setup({'cycle08': '{% cycle a,b,c as foo %}{% cycle foo %}{{ foo }}{{ foo }}{% cycle foo %}{{ foo }}'}) def test_cycle08(self): - output = render('cycle08') + output = self.engine.render_to_string('cycle08') self.assertEqual(output, 'abbbcc') @setup({'cycle09': '{% for i in test %}{% cycle a,b %}{{ i }},{% endfor %}'}) def test_cycle09(self): - output = render('cycle09', {'test': list(range(5))}) + output = self.engine.render_to_string('cycle09', {'test': list(range(5))}) self.assertEqual(output, 'a0,b1,a2,b3,a4,') @setup({'cycle10': "{% cycle 'a' 'b' 'c' as abc %}{% cycle abc %}"}) def test_cycle10(self): - output = render('cycle10') + output = self.engine.render_to_string('cycle10') self.assertEqual(output, 'ab') @setup({'cycle11': "{% cycle 'a' 'b' 'c' as abc %}{% cycle abc %}{% cycle abc %}"}) def test_cycle11(self): - output = render('cycle11') + output = self.engine.render_to_string('cycle11') self.assertEqual(output, 'abc') @setup({'cycle12': "{% cycle 'a' 'b' 'c' as abc %}{% cycle abc %}{% cycle abc %}{% cycle abc %}"}) def test_cycle12(self): - output = render('cycle12') + output = self.engine.render_to_string('cycle12') self.assertEqual(output, 'abca') @setup({'cycle13': "{% for i in test %}{% cycle 'a' 'b' %}{{ i }},{% endfor %}"}) def test_cycle13(self): - output = render('cycle13', {'test': list(range(5))}) + output = self.engine.render_to_string('cycle13', {'test': list(range(5))}) self.assertEqual(output, 'a0,b1,a2,b3,a4,') @setup({'cycle14': '{% cycle one two as foo %}{% cycle foo %}'}) def test_cycle14(self): - output = render('cycle14', {'one': '1', 'two': '2'}) + output = self.engine.render_to_string('cycle14', {'one': '1', 'two': '2'}) self.assertEqual(output, '12') @setup({'cycle15': '{% for i in test %}{% cycle aye bee %}{{ i }},{% endfor %}'}) def test_cycle15(self): - output = render('cycle15', {'test': list(range(5)), 'aye': 'a', 'bee': 'b'}) + output = self.engine.render_to_string('cycle15', {'test': list(range(5)), 'aye': 'a', 'bee': 'b'}) self.assertEqual(output, 'a0,b1,a2,b3,a4,') @setup({'cycle16': '{% cycle one|lower two as foo %}{% cycle foo %}'}) def test_cycle16(self): - output = render('cycle16', {'one': 'A', 'two': '2'}) + output = self.engine.render_to_string('cycle16', {'one': 'A', 'two': '2'}) self.assertEqual(output, 'a2') @setup({'cycle17': "{% cycle 'a' 'b' 'c' as abc silent %}" "{% cycle abc %}{% cycle abc %}{% cycle abc %}{% cycle abc %}"}) def test_cycle17(self): - output = render('cycle17') + output = self.engine.render_to_string('cycle17') self.assertEqual(output, '') @setup({'cycle18': "{% cycle 'a' 'b' 'c' as foo invalid_flag %}"}) def test_cycle18(self): with self.assertRaises(TemplateSyntaxError): - get_template('cycle18') + self.engine.get_template('cycle18') @setup({'cycle19': "{% cycle 'a' 'b' as silent %}{% cycle silent %}"}) def test_cycle19(self): - output = render('cycle19') + output = self.engine.render_to_string('cycle19') self.assertEqual(output, 'ab') @setup({'cycle20': '{% cycle one two as foo %} & {% cycle foo %}'}) def test_cycle20(self): - output = render('cycle20', {'two': 'C & D', 'one': 'A & B'}) + output = self.engine.render_to_string('cycle20', {'two': 'C & D', 'one': 'A & B'}) self.assertEqual(output, 'A & B & C & D') @setup({'cycle21': '{% filter force_escape %}' '{% cycle one two as foo %} & {% cycle foo %}{% endfilter %}'}) def test_cycle21(self): - output = render('cycle21', {'two': 'C & D', 'one': 'A & B'}) + output = self.engine.render_to_string('cycle21', {'two': 'C & D', 'one': 'A & B'}) self.assertEqual(output, 'A &amp; B & C &amp; D') @setup({'cycle22': "{% for x in values %}{% cycle 'a' 'b' 'c' as abc silent %}{{ x }}{% endfor %}"}) def test_cycle22(self): - output = render('cycle22', {'values': [1, 2, 3, 4]}) + output = self.engine.render_to_string('cycle22', {'values': [1, 2, 3, 4]}) self.assertEqual(output, '1234') @setup({'cycle23': "{% for x in values %}" "{% cycle 'a' 'b' 'c' as abc silent %}{{ abc }}{{ x }}{% endfor %}"}) def test_cycle23(self): - output = render('cycle23', {'values': [1, 2, 3, 4]}) + output = self.engine.render_to_string('cycle23', {'values': [1, 2, 3, 4]}) self.assertEqual(output, 'a1b2c3a4') @setup({ @@ -134,19 +133,19 @@ class CycleTagTests(SimpleTestCase): 'included-cycle': '{{ abc }}', }) def test_cycle24(self): - output = render('cycle24', {'values': [1, 2, 3, 4]}) + output = self.engine.render_to_string('cycle24', {'values': [1, 2, 3, 4]}) self.assertEqual(output, 'abca') @setup({'cycle25': '{% cycle a as abc %}'}) def test_cycle25(self): - output = render('cycle25', {'a': '<'}) + output = self.engine.render_to_string('cycle25', {'a': '<'}) self.assertEqual(output, '<') @setup({'cycle26': '{% load cycle from future %}{% cycle a b as ab %}{% cycle ab %}'}) def test_cycle26(self): with warnings.catch_warnings(): warnings.simplefilter("ignore", RemovedInDjango20Warning) - output = render('cycle26', {'a': '<', 'b': '>'}) + output = self.engine.render_to_string('cycle26', {'a': '<', 'b': '>'}) self.assertEqual(output, '<>') @setup({'cycle27': '{% load cycle from future %}' @@ -154,12 +153,12 @@ class CycleTagTests(SimpleTestCase): def test_cycle27(self): with warnings.catch_warnings(): warnings.simplefilter("ignore", RemovedInDjango20Warning) - output = render('cycle27', {'a': '<', 'b': '>'}) + output = self.engine.render_to_string('cycle27', {'a': '<', 'b': '>'}) self.assertEqual(output, '<>') @setup({'cycle28': '{% load cycle from future %}{% cycle a|safe b as ab %}{% cycle ab %}'}) def test_cycle28(self): with warnings.catch_warnings(): warnings.simplefilter("ignore", RemovedInDjango20Warning) - output = render('cycle28', {'a': '<', 'b': '>'}) + output = self.engine.render_to_string('cycle28', {'a': '<', 'b': '>'}) self.assertEqual(output, '<>') |
