Loading tests/template_tests/filter_tests/test_add.py +8 −8 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ from datetime import date, timedelta from django.template.defaultfilters import add from django.test import SimpleTestCase from ..utils import render, setup from ..utils import setup class AddTests(SimpleTestCase): Loading @@ -13,37 +13,37 @@ class AddTests(SimpleTestCase): @setup({'add01': '{{ i|add:"5" }}'}) def test_add01(self): output = render('add01', {'i': 2000}) output = self.engine.render_to_string('add01', {'i': 2000}) self.assertEqual(output, '2005') @setup({'add02': '{{ i|add:"napis" }}'}) def test_add02(self): output = render('add02', {'i': 2000}) output = self.engine.render_to_string('add02', {'i': 2000}) self.assertEqual(output, '') @setup({'add03': '{{ i|add:16 }}'}) def test_add03(self): output = render('add03', {'i': 'not_an_int'}) output = self.engine.render_to_string('add03', {'i': 'not_an_int'}) self.assertEqual(output, '') @setup({'add04': '{{ i|add:"16" }}'}) def test_add04(self): output = render('add04', {'i': 'not_an_int'}) output = self.engine.render_to_string('add04', {'i': 'not_an_int'}) self.assertEqual(output, 'not_an_int16') @setup({'add05': '{{ l1|add:l2 }}'}) def test_add05(self): output = render('add05', {'l1': [1, 2], 'l2': [3, 4]}) output = self.engine.render_to_string('add05', {'l1': [1, 2], 'l2': [3, 4]}) self.assertEqual(output, '[1, 2, 3, 4]') @setup({'add06': '{{ t1|add:t2 }}'}) def test_add06(self): output = render('add06', {'t1': (3, 4), 't2': (1, 2)}) output = self.engine.render_to_string('add06', {'t1': (3, 4), 't2': (1, 2)}) self.assertEqual(output, '(3, 4, 1, 2)') @setup({'add07': '{{ d|add:t }}'}) def test_add07(self): output = render('add07', {'d': date(2000, 1, 1), 't': timedelta(10)}) output = self.engine.render_to_string('add07', {'d': date(2000, 1, 1), 't': timedelta(10)}) self.assertEqual(output, 'Jan. 11, 2000') Loading tests/template_tests/filter_tests/test_addslashes.py +3 −3 Original line number Diff line number Diff line Loading @@ -2,19 +2,19 @@ from django.template.defaultfilters import addslashes from django.test import SimpleTestCase from django.utils.safestring import mark_safe from ..utils import render, setup from ..utils import setup class AddslashesTests(SimpleTestCase): @setup({'addslashes01': '{% autoescape off %}{{ a|addslashes }} {{ b|addslashes }}{% endautoescape %}'}) def test_addslashes01(self): output = render('addslashes01', {"a": "<a>'", "b": mark_safe("<a>'")}) output = self.engine.render_to_string('addslashes01', {"a": "<a>'", "b": mark_safe("<a>'")}) self.assertEqual(output, r"<a>\' <a>\'") @setup({'addslashes02': '{{ a|addslashes }} {{ b|addslashes }}'}) def test_addslashes02(self): output = render('addslashes02', {"a": "<a>'", "b": mark_safe("<a>'")}) output = self.engine.render_to_string('addslashes02', {"a": "<a>'", "b": mark_safe("<a>'")}) self.assertEqual(output, r"<a>\' <a>\'") Loading tests/template_tests/filter_tests/test_autoescape.py +5 −5 Original line number Diff line number Diff line from django.test import SimpleTestCase from ..utils import render, setup, SafeClass, UnsafeClass from ..utils import setup, SafeClass, UnsafeClass class AutoescapeStringfilterTests(SimpleTestCase): Loading @@ -10,20 +10,20 @@ class AutoescapeStringfilterTests(SimpleTestCase): @setup({'autoescape-stringfilter01': '{{ unsafe|capfirst }}'}) def test_autoescape_stringfilter01(self): output = render('autoescape-stringfilter01', {'unsafe': UnsafeClass()}) output = self.engine.render_to_string('autoescape-stringfilter01', {'unsafe': UnsafeClass()}) self.assertEqual(output, 'You & me') @setup({'autoescape-stringfilter02': '{% autoescape off %}{{ unsafe|capfirst }}{% endautoescape %}'}) def test_autoescape_stringfilter02(self): output = render('autoescape-stringfilter02', {'unsafe': UnsafeClass()}) output = self.engine.render_to_string('autoescape-stringfilter02', {'unsafe': UnsafeClass()}) self.assertEqual(output, 'You & me') @setup({'autoescape-stringfilter03': '{{ safe|capfirst }}'}) def test_autoescape_stringfilter03(self): output = render('autoescape-stringfilter03', {'safe': SafeClass()}) output = self.engine.render_to_string('autoescape-stringfilter03', {'safe': SafeClass()}) self.assertEqual(output, 'You > me') @setup({'autoescape-stringfilter04': '{% autoescape off %}{{ safe|capfirst }}{% endautoescape %}'}) def test_autoescape_stringfilter04(self): output = render('autoescape-stringfilter04', {'safe': SafeClass()}) output = self.engine.render_to_string('autoescape-stringfilter04', {'safe': SafeClass()}) self.assertEqual(output, 'You > me') tests/template_tests/filter_tests/test_capfirst.py +3 −3 Original line number Diff line number Diff line Loading @@ -2,19 +2,19 @@ from django.template.defaultfilters import capfirst from django.test import SimpleTestCase from django.utils.safestring import mark_safe from ..utils import render, setup from ..utils import setup class CapfirstTests(SimpleTestCase): @setup({'capfirst01': '{% autoescape off %}{{ a|capfirst }} {{ b|capfirst }}{% endautoescape %}'}) def test_capfirst01(self): output = render('capfirst01', {'a': 'fred>', 'b': mark_safe('fred>')}) output = self.engine.render_to_string('capfirst01', {'a': 'fred>', 'b': mark_safe('fred>')}) self.assertEqual(output, 'Fred> Fred>') @setup({'capfirst02': '{{ a|capfirst }} {{ b|capfirst }}'}) def test_capfirst02(self): output = render('capfirst02', {'a': 'fred>', 'b': mark_safe('fred>')}) output = self.engine.render_to_string('capfirst02', {'a': 'fred>', 'b': mark_safe('fred>')}) self.assertEqual(output, 'Fred> Fred>') Loading tests/template_tests/filter_tests/test_center.py +3 −3 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ from django.template.defaultfilters import center from django.test import SimpleTestCase from django.utils.safestring import mark_safe from ..utils import render, setup from ..utils import setup class CenterTests(SimpleTestCase): Loading @@ -10,12 +10,12 @@ class CenterTests(SimpleTestCase): @setup({'center01': '{% autoescape off %}.{{ a|center:"5" }}. .{{ b|center:"5" }}.{% endautoescape %}'}) def test_center01(self): output = render('center01', {"a": "a&b", "b": mark_safe("a&b")}) output = self.engine.render_to_string('center01', {"a": "a&b", "b": mark_safe("a&b")}) self.assertEqual(output, ". a&b . . a&b .") @setup({'center02': '.{{ a|center:"5" }}. .{{ b|center:"5" }}.'}) def test_center02(self): output = render('center02', {"a": "a&b", "b": mark_safe("a&b")}) output = self.engine.render_to_string('center02', {"a": "a&b", "b": mark_safe("a&b")}) self.assertEqual(output, ". a&b . . a&b .") Loading Loading
tests/template_tests/filter_tests/test_add.py +8 −8 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ from datetime import date, timedelta from django.template.defaultfilters import add from django.test import SimpleTestCase from ..utils import render, setup from ..utils import setup class AddTests(SimpleTestCase): Loading @@ -13,37 +13,37 @@ class AddTests(SimpleTestCase): @setup({'add01': '{{ i|add:"5" }}'}) def test_add01(self): output = render('add01', {'i': 2000}) output = self.engine.render_to_string('add01', {'i': 2000}) self.assertEqual(output, '2005') @setup({'add02': '{{ i|add:"napis" }}'}) def test_add02(self): output = render('add02', {'i': 2000}) output = self.engine.render_to_string('add02', {'i': 2000}) self.assertEqual(output, '') @setup({'add03': '{{ i|add:16 }}'}) def test_add03(self): output = render('add03', {'i': 'not_an_int'}) output = self.engine.render_to_string('add03', {'i': 'not_an_int'}) self.assertEqual(output, '') @setup({'add04': '{{ i|add:"16" }}'}) def test_add04(self): output = render('add04', {'i': 'not_an_int'}) output = self.engine.render_to_string('add04', {'i': 'not_an_int'}) self.assertEqual(output, 'not_an_int16') @setup({'add05': '{{ l1|add:l2 }}'}) def test_add05(self): output = render('add05', {'l1': [1, 2], 'l2': [3, 4]}) output = self.engine.render_to_string('add05', {'l1': [1, 2], 'l2': [3, 4]}) self.assertEqual(output, '[1, 2, 3, 4]') @setup({'add06': '{{ t1|add:t2 }}'}) def test_add06(self): output = render('add06', {'t1': (3, 4), 't2': (1, 2)}) output = self.engine.render_to_string('add06', {'t1': (3, 4), 't2': (1, 2)}) self.assertEqual(output, '(3, 4, 1, 2)') @setup({'add07': '{{ d|add:t }}'}) def test_add07(self): output = render('add07', {'d': date(2000, 1, 1), 't': timedelta(10)}) output = self.engine.render_to_string('add07', {'d': date(2000, 1, 1), 't': timedelta(10)}) self.assertEqual(output, 'Jan. 11, 2000') Loading
tests/template_tests/filter_tests/test_addslashes.py +3 −3 Original line number Diff line number Diff line Loading @@ -2,19 +2,19 @@ from django.template.defaultfilters import addslashes from django.test import SimpleTestCase from django.utils.safestring import mark_safe from ..utils import render, setup from ..utils import setup class AddslashesTests(SimpleTestCase): @setup({'addslashes01': '{% autoescape off %}{{ a|addslashes }} {{ b|addslashes }}{% endautoescape %}'}) def test_addslashes01(self): output = render('addslashes01', {"a": "<a>'", "b": mark_safe("<a>'")}) output = self.engine.render_to_string('addslashes01', {"a": "<a>'", "b": mark_safe("<a>'")}) self.assertEqual(output, r"<a>\' <a>\'") @setup({'addslashes02': '{{ a|addslashes }} {{ b|addslashes }}'}) def test_addslashes02(self): output = render('addslashes02', {"a": "<a>'", "b": mark_safe("<a>'")}) output = self.engine.render_to_string('addslashes02', {"a": "<a>'", "b": mark_safe("<a>'")}) self.assertEqual(output, r"<a>\' <a>\'") Loading
tests/template_tests/filter_tests/test_autoescape.py +5 −5 Original line number Diff line number Diff line from django.test import SimpleTestCase from ..utils import render, setup, SafeClass, UnsafeClass from ..utils import setup, SafeClass, UnsafeClass class AutoescapeStringfilterTests(SimpleTestCase): Loading @@ -10,20 +10,20 @@ class AutoescapeStringfilterTests(SimpleTestCase): @setup({'autoescape-stringfilter01': '{{ unsafe|capfirst }}'}) def test_autoescape_stringfilter01(self): output = render('autoescape-stringfilter01', {'unsafe': UnsafeClass()}) output = self.engine.render_to_string('autoescape-stringfilter01', {'unsafe': UnsafeClass()}) self.assertEqual(output, 'You & me') @setup({'autoescape-stringfilter02': '{% autoescape off %}{{ unsafe|capfirst }}{% endautoescape %}'}) def test_autoescape_stringfilter02(self): output = render('autoescape-stringfilter02', {'unsafe': UnsafeClass()}) output = self.engine.render_to_string('autoescape-stringfilter02', {'unsafe': UnsafeClass()}) self.assertEqual(output, 'You & me') @setup({'autoescape-stringfilter03': '{{ safe|capfirst }}'}) def test_autoescape_stringfilter03(self): output = render('autoescape-stringfilter03', {'safe': SafeClass()}) output = self.engine.render_to_string('autoescape-stringfilter03', {'safe': SafeClass()}) self.assertEqual(output, 'You > me') @setup({'autoescape-stringfilter04': '{% autoescape off %}{{ safe|capfirst }}{% endautoescape %}'}) def test_autoescape_stringfilter04(self): output = render('autoescape-stringfilter04', {'safe': SafeClass()}) output = self.engine.render_to_string('autoescape-stringfilter04', {'safe': SafeClass()}) self.assertEqual(output, 'You > me')
tests/template_tests/filter_tests/test_capfirst.py +3 −3 Original line number Diff line number Diff line Loading @@ -2,19 +2,19 @@ from django.template.defaultfilters import capfirst from django.test import SimpleTestCase from django.utils.safestring import mark_safe from ..utils import render, setup from ..utils import setup class CapfirstTests(SimpleTestCase): @setup({'capfirst01': '{% autoescape off %}{{ a|capfirst }} {{ b|capfirst }}{% endautoescape %}'}) def test_capfirst01(self): output = render('capfirst01', {'a': 'fred>', 'b': mark_safe('fred>')}) output = self.engine.render_to_string('capfirst01', {'a': 'fred>', 'b': mark_safe('fred>')}) self.assertEqual(output, 'Fred> Fred>') @setup({'capfirst02': '{{ a|capfirst }} {{ b|capfirst }}'}) def test_capfirst02(self): output = render('capfirst02', {'a': 'fred>', 'b': mark_safe('fred>')}) output = self.engine.render_to_string('capfirst02', {'a': 'fred>', 'b': mark_safe('fred>')}) self.assertEqual(output, 'Fred> Fred>') Loading
tests/template_tests/filter_tests/test_center.py +3 −3 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ from django.template.defaultfilters import center from django.test import SimpleTestCase from django.utils.safestring import mark_safe from ..utils import render, setup from ..utils import setup class CenterTests(SimpleTestCase): Loading @@ -10,12 +10,12 @@ class CenterTests(SimpleTestCase): @setup({'center01': '{% autoescape off %}.{{ a|center:"5" }}. .{{ b|center:"5" }}.{% endautoescape %}'}) def test_center01(self): output = render('center01', {"a": "a&b", "b": mark_safe("a&b")}) output = self.engine.render_to_string('center01', {"a": "a&b", "b": mark_safe("a&b")}) self.assertEqual(output, ". a&b . . a&b .") @setup({'center02': '.{{ a|center:"5" }}. .{{ b|center:"5" }}.'}) def test_center02(self): output = render('center02', {"a": "a&b", "b": mark_safe("a&b")}) output = self.engine.render_to_string('center02', {"a": "a&b", "b": mark_safe("a&b")}) self.assertEqual(output, ". a&b . . a&b .") Loading