diff --git a/tests/template_tests/filter_tests/test_add.py b/tests/template_tests/filter_tests/test_add.py
index 802c1cfe190..0fcc661f4ae 100644
--- a/tests/template_tests/filter_tests/test_add.py
+++ b/tests/template_tests/filter_tests/test_add.py
@@ -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):
@@ -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')
diff --git a/tests/template_tests/filter_tests/test_addslashes.py b/tests/template_tests/filter_tests/test_addslashes.py
index 7be84c02207..9c6abd8684d 100644
--- a/tests/template_tests/filter_tests/test_addslashes.py
+++ b/tests/template_tests/filter_tests/test_addslashes.py
@@ -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": "'", "b": mark_safe("'")})
+ output = self.engine.render_to_string('addslashes01', {"a": "'", "b": mark_safe("'")})
self.assertEqual(output, r"\' \'")
@setup({'addslashes02': '{{ a|addslashes }} {{ b|addslashes }}'})
def test_addslashes02(self):
- output = render('addslashes02', {"a": "'", "b": mark_safe("'")})
+ output = self.engine.render_to_string('addslashes02', {"a": "'", "b": mark_safe("'")})
self.assertEqual(output, r"<a>\' \'")
diff --git a/tests/template_tests/filter_tests/test_autoescape.py b/tests/template_tests/filter_tests/test_autoescape.py
index 159e1fad3e4..793fbf80d60 100644
--- a/tests/template_tests/filter_tests/test_autoescape.py
+++ b/tests/template_tests/filter_tests/test_autoescape.py
@@ -1,6 +1,6 @@
from django.test import SimpleTestCase
-from ..utils import render, setup, SafeClass, UnsafeClass
+from ..utils import setup, SafeClass, UnsafeClass
class AutoescapeStringfilterTests(SimpleTestCase):
@@ -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')
diff --git a/tests/template_tests/filter_tests/test_capfirst.py b/tests/template_tests/filter_tests/test_capfirst.py
index d7a28130f93..bcdf1e0203b 100644
--- a/tests/template_tests/filter_tests/test_capfirst.py
+++ b/tests/template_tests/filter_tests/test_capfirst.py
@@ -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>')
diff --git a/tests/template_tests/filter_tests/test_center.py b/tests/template_tests/filter_tests/test_center.py
index 0dbb1002b71..306de331017 100644
--- a/tests/template_tests/filter_tests/test_center.py
+++ b/tests/template_tests/filter_tests/test_center.py
@@ -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):
@@ -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 .")
diff --git a/tests/template_tests/filter_tests/test_chaining.py b/tests/template_tests/filter_tests/test_chaining.py
index 964bc4b873c..1704715191e 100644
--- a/tests/template_tests/filter_tests/test_chaining.py
+++ b/tests/template_tests/filter_tests/test_chaining.py
@@ -1,7 +1,7 @@
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
-from ..utils import render, setup
+from ..utils import setup
class ChainingTests(SimpleTestCase):
@@ -11,76 +11,76 @@ class ChainingTests(SimpleTestCase):
@setup({'chaining01': '{{ a|capfirst|center:"7" }}.{{ b|capfirst|center:"7" }}'})
def test_chaining01(self):
- output = render('chaining01', {'a': 'a < b', 'b': mark_safe('a < b')})
+ output = self.engine.render_to_string('chaining01', {'a': 'a < b', 'b': mark_safe('a < b')})
self.assertEqual(output, ' A < b . A < b ')
@setup({'chaining02':
'{% autoescape off %}{{ a|capfirst|center:"7" }}.{{ b|capfirst|center:"7" }}{% endautoescape %}'})
def test_chaining02(self):
- output = render('chaining02', {'a': 'a < b', 'b': mark_safe('a < b')})
+ output = self.engine.render_to_string('chaining02', {'a': 'a < b', 'b': mark_safe('a < b')})
self.assertEqual(output, ' A < b . A < b ')
# Using a filter that forces a string back to unsafe:
@setup({'chaining03': '{{ a|cut:"b"|capfirst }}.{{ b|cut:"b"|capfirst }}'})
def test_chaining03(self):
- output = render('chaining03', {'a': 'a < b', 'b': mark_safe('a < b')})
+ output = self.engine.render_to_string('chaining03', {'a': 'a < b', 'b': mark_safe('a < b')})
self.assertEqual(output, 'A < .A < ')
@setup({'chaining04':
'{% autoescape off %}{{ a|cut:"b"|capfirst }}.{{ b|cut:"b"|capfirst }}{% endautoescape %}'})
def test_chaining04(self):
- output = render('chaining04', {'a': 'a < b', 'b': mark_safe('a < b')})
+ output = self.engine.render_to_string('chaining04', {'a': 'a < b', 'b': mark_safe('a < b')})
self.assertEqual(output, 'A < .A < ')
# Using a filter that forces safeness does not lead to double-escaping
@setup({'chaining05': '{{ a|escape|capfirst }}'})
def test_chaining05(self):
- output = render('chaining05', {'a': 'a < b'})
+ output = self.engine.render_to_string('chaining05', {'a': 'a < b'})
self.assertEqual(output, 'A < b')
@setup({'chaining06': '{% autoescape off %}{{ a|escape|capfirst }}{% endautoescape %}'})
def test_chaining06(self):
- output = render('chaining06', {'a': 'a < b'})
+ output = self.engine.render_to_string('chaining06', {'a': 'a < b'})
self.assertEqual(output, 'A < b')
# Force to safe, then back (also showing why using force_escape too
# early in a chain can lead to unexpected results).
@setup({'chaining07': '{{ a|force_escape|cut:";" }}'})
def test_chaining07(self):
- output = render('chaining07', {'a': 'a < b'})
+ output = self.engine.render_to_string('chaining07', {'a': 'a < b'})
self.assertEqual(output, 'a < b')
@setup({'chaining08': '{% autoescape off %}{{ a|force_escape|cut:";" }}{% endautoescape %}'})
def test_chaining08(self):
- output = render('chaining08', {'a': 'a < b'})
+ output = self.engine.render_to_string('chaining08', {'a': 'a < b'})
self.assertEqual(output, 'a < b')
@setup({'chaining09': '{{ a|cut:";"|force_escape }}'})
def test_chaining09(self):
- output = render('chaining09', {'a': 'a < b'})
+ output = self.engine.render_to_string('chaining09', {'a': 'a < b'})
self.assertEqual(output, 'a < b')
@setup({'chaining10': '{% autoescape off %}{{ a|cut:";"|force_escape }}{% endautoescape %}'})
def test_chaining10(self):
- output = render('chaining10', {'a': 'a < b'})
+ output = self.engine.render_to_string('chaining10', {'a': 'a < b'})
self.assertEqual(output, 'a < b')
@setup({'chaining11': '{{ a|cut:"b"|safe }}'})
def test_chaining11(self):
- output = render('chaining11', {'a': 'a < b'})
+ output = self.engine.render_to_string('chaining11', {'a': 'a < b'})
self.assertEqual(output, 'a < ')
@setup({'chaining12': '{% autoescape off %}{{ a|cut:"b"|safe }}{% endautoescape %}'})
def test_chaining12(self):
- output = render('chaining12', {'a': 'a < b'})
+ output = self.engine.render_to_string('chaining12', {'a': 'a < b'})
self.assertEqual(output, 'a < ')
@setup({'chaining13': '{{ a|safe|force_escape }}'})
def test_chaining13(self):
- output = render('chaining13', {"a": "a < b"})
+ output = self.engine.render_to_string('chaining13', {"a": "a < b"})
self.assertEqual(output, 'a < b')
@setup({'chaining14': '{% autoescape off %}{{ a|safe|force_escape }}{% endautoescape %}'})
def test_chaining14(self):
- output = render('chaining14', {"a": "a < b"})
+ output = self.engine.render_to_string('chaining14', {"a": "a < b"})
self.assertEqual(output, 'a < b')
diff --git a/tests/template_tests/filter_tests/test_cut.py b/tests/template_tests/filter_tests/test_cut.py
index fde23266bae..6b4baa26451 100644
--- a/tests/template_tests/filter_tests/test_cut.py
+++ b/tests/template_tests/filter_tests/test_cut.py
@@ -2,41 +2,41 @@ from django.template.defaultfilters import cut
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
-from ..utils import render, setup
+from ..utils import setup
class CutTests(SimpleTestCase):
@setup({'cut01': '{% autoescape off %}{{ a|cut:"x" }} {{ b|cut:"x" }}{% endautoescape %}'})
def test_cut01(self):
- output = render('cut01', {"a": "x&y", "b": mark_safe("x&y")})
+ output = self.engine.render_to_string('cut01', {"a": "x&y", "b": mark_safe("x&y")})
self.assertEqual(output, "&y &y")
@setup({'cut02': '{{ a|cut:"x" }} {{ b|cut:"x" }}'})
def test_cut02(self):
- output = render('cut02', {"a": "x&y", "b": mark_safe("x&y")})
+ output = self.engine.render_to_string('cut02', {"a": "x&y", "b": mark_safe("x&y")})
self.assertEqual(output, "&y &y")
@setup({'cut03': '{% autoescape off %}{{ a|cut:"&" }} {{ b|cut:"&" }}{% endautoescape %}'})
def test_cut03(self):
- output = render('cut03', {"a": "x&y", "b": mark_safe("x&y")})
+ output = self.engine.render_to_string('cut03', {"a": "x&y", "b": mark_safe("x&y")})
self.assertEqual(output, "xy xamp;y")
@setup({'cut04': '{{ a|cut:"&" }} {{ b|cut:"&" }}'})
def test_cut04(self):
- output = render('cut04', {"a": "x&y", "b": mark_safe("x&y")})
+ output = self.engine.render_to_string('cut04', {"a": "x&y", "b": mark_safe("x&y")})
self.assertEqual(output, "xy xamp;y")
# Passing ';' to cut can break existing HTML entities, so those strings
# are auto-escaped.
@setup({'cut05': '{% autoescape off %}{{ a|cut:";" }} {{ b|cut:";" }}{% endautoescape %}'})
def test_cut05(self):
- output = render('cut05', {"a": "x&y", "b": mark_safe("x&y")})
+ output = self.engine.render_to_string('cut05', {"a": "x&y", "b": mark_safe("x&y")})
self.assertEqual(output, "x&y x&y")
@setup({'cut06': '{{ a|cut:";" }} {{ b|cut:";" }}'})
def test_cut06(self):
- output = render('cut06', {"a": "x&y", "b": mark_safe("x&y")})
+ output = self.engine.render_to_string('cut06', {"a": "x&y", "b": mark_safe("x&y")})
self.assertEqual(output, "x&y x&y")
diff --git a/tests/template_tests/filter_tests/test_date.py b/tests/template_tests/filter_tests/test_date.py
index e546dae4303..8485e10a198 100644
--- a/tests/template_tests/filter_tests/test_date.py
+++ b/tests/template_tests/filter_tests/test_date.py
@@ -5,19 +5,19 @@ from django.test import SimpleTestCase
from django.utils import timezone
from .timezone_utils import TimezoneTestCase
-from ..utils import render, setup
+from ..utils import setup
class DateTests(TimezoneTestCase):
@setup({'date01': '{{ d|date:"m" }}'})
def test_date01(self):
- output = render('date01', {'d': datetime(2008, 1, 1)})
+ output = self.engine.render_to_string('date01', {'d': datetime(2008, 1, 1)})
self.assertEqual(output, '01')
@setup({'date02': '{{ d|date }}'})
def test_date02(self):
- output = render('date02', {'d': datetime(2008, 1, 1)})
+ output = self.engine.render_to_string('date02', {'d': datetime(2008, 1, 1)})
self.assertEqual(output, 'Jan. 1, 2008')
@setup({'date03': '{{ d|date:"m" }}'})
@@ -25,40 +25,40 @@ class DateTests(TimezoneTestCase):
"""
#9520: Make sure |date doesn't blow up on non-dates
"""
- output = render('date03', {'d': 'fail_string'})
+ output = self.engine.render_to_string('date03', {'d': 'fail_string'})
self.assertEqual(output, '')
# ISO date formats
@setup({'date04': '{{ d|date:"o" }}'})
def test_date04(self):
- output = render('date04', {'d': datetime(2008, 12, 29)})
+ output = self.engine.render_to_string('date04', {'d': datetime(2008, 12, 29)})
self.assertEqual(output, '2009')
@setup({'date05': '{{ d|date:"o" }}'})
def test_date05(self):
- output = render('date05', {'d': datetime(2010, 1, 3)})
+ output = self.engine.render_to_string('date05', {'d': datetime(2010, 1, 3)})
self.assertEqual(output, '2009')
# Timezone name
@setup({'date06': '{{ d|date:"e" }}'})
def test_date06(self):
- output = render('date06', {'d': datetime(2009, 3, 12, tzinfo=timezone.get_fixed_timezone(30))})
+ output = self.engine.render_to_string('date06', {'d': datetime(2009, 3, 12, tzinfo=timezone.get_fixed_timezone(30))})
self.assertEqual(output, '+0030')
@setup({'date07': '{{ d|date:"e" }}'})
def test_date07(self):
- output = render('date07', {'d': datetime(2009, 3, 12)})
+ output = self.engine.render_to_string('date07', {'d': datetime(2009, 3, 12)})
self.assertEqual(output, '')
# #19370: Make sure |date doesn't blow up on a midnight time object
@setup({'date08': '{{ t|date:"H:i" }}'})
def test_date08(self):
- output = render('date08', {'t': time(0, 1)})
+ output = self.engine.render_to_string('date08', {'t': time(0, 1)})
self.assertEqual(output, '00:01')
@setup({'date09': '{{ t|date:"H:i" }}'})
def test_date09(self):
- output = render('date09', {'t': time(0, 0)})
+ output = self.engine.render_to_string('date09', {'t': time(0, 0)})
self.assertEqual(output, '00:00')
diff --git a/tests/template_tests/filter_tests/test_default.py b/tests/template_tests/filter_tests/test_default.py
index 766957ba358..4b6b9dd6845 100644
--- a/tests/template_tests/filter_tests/test_default.py
+++ b/tests/template_tests/filter_tests/test_default.py
@@ -2,7 +2,7 @@ from django.template.defaultfilters import default
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
-from ..utils import render, setup
+from ..utils import setup
class DefaultTests(SimpleTestCase):
@@ -16,22 +16,22 @@ class DefaultTests(SimpleTestCase):
@setup({'default01': '{{ a|default:"x<" }}'})
def test_default01(self):
- output = render('default01', {"a": ""})
+ output = self.engine.render_to_string('default01', {"a": ""})
self.assertEqual(output, "x<")
@setup({'default02': '{% autoescape off %}{{ a|default:"x<" }}{% endautoescape %}'})
def test_default02(self):
- output = render('default02', {"a": ""})
+ output = self.engine.render_to_string('default02', {"a": ""})
self.assertEqual(output, "x<")
@setup({'default03': '{{ a|default:"x<" }}'})
def test_default03(self):
- output = render('default03', {"a": mark_safe("x>")})
+ output = self.engine.render_to_string('default03', {"a": mark_safe("x>")})
self.assertEqual(output, "x>")
@setup({'default04': '{% autoescape off %}{{ a|default:"x<" }}{% endautoescape %}'})
def test_default04(self):
- output = render('default04', {"a": mark_safe("x>")})
+ output = self.engine.render_to_string('default04', {"a": mark_safe("x>")})
self.assertEqual(output, "x>")
@@ -39,12 +39,12 @@ class DefaultIfNoneTests(SimpleTestCase):
@setup({'default_if_none01': '{{ a|default:"x<" }}'})
def test_default_if_none01(self):
- output = render('default_if_none01', {"a": None})
+ output = self.engine.render_to_string('default_if_none01', {"a": None})
self.assertEqual(output, "x<")
@setup({'default_if_none02': '{% autoescape off %}{{ a|default:"x<" }}{% endautoescape %}'})
def test_default_if_none02(self):
- output = render('default_if_none02', {"a": None})
+ output = self.engine.render_to_string('default_if_none02', {"a": None})
self.assertEqual(output, "x<")
diff --git a/tests/template_tests/filter_tests/test_escape.py b/tests/template_tests/filter_tests/test_escape.py
index 094bf575cec..83bfb36444b 100644
--- a/tests/template_tests/filter_tests/test_escape.py
+++ b/tests/template_tests/filter_tests/test_escape.py
@@ -2,7 +2,7 @@ from django.template.defaultfilters import escape
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
-from ..utils import render, setup
+from ..utils import setup
class EscapeTests(SimpleTestCase):
@@ -13,24 +13,24 @@ class EscapeTests(SimpleTestCase):
@setup({'escape01': '{{ a|escape }} {{ b|escape }}'})
def test_escape01(self):
- output = render('escape01', {"a": "x&y", "b": mark_safe("x&y")})
+ output = self.engine.render_to_string('escape01', {"a": "x&y", "b": mark_safe("x&y")})
self.assertEqual(output, "x&y x&y")
@setup({'escape02': '{% autoescape off %}{{ a|escape }} {{ b|escape }}{% endautoescape %}'})
def test_escape02(self):
- output = render('escape02', {"a": "x&y", "b": mark_safe("x&y")})
+ output = self.engine.render_to_string('escape02', {"a": "x&y", "b": mark_safe("x&y")})
self.assertEqual(output, "x&y x&y")
# It is only applied once, regardless of the number of times it
# appears in a chain.
@setup({'escape03': '{% autoescape off %}{{ a|escape|escape }}{% endautoescape %}'})
def test_escape03(self):
- output = render('escape03', {"a": "x&y"})
+ output = self.engine.render_to_string('escape03', {"a": "x&y"})
self.assertEqual(output, "x&y")
@setup({'escape04': '{{ a|escape|escape }}'})
def test_escape04(self):
- output = render('escape04', {"a": "x&y"})
+ output = self.engine.render_to_string('escape04', {"a": "x&y"})
self.assertEqual(output, "x&y")
diff --git a/tests/template_tests/filter_tests/test_escapejs.py b/tests/template_tests/filter_tests/test_escapejs.py
index d124be16679..b913aeb1c0f 100644
--- a/tests/template_tests/filter_tests/test_escapejs.py
+++ b/tests/template_tests/filter_tests/test_escapejs.py
@@ -3,21 +3,21 @@ from __future__ import unicode_literals
from django.template.defaultfilters import escapejs_filter
from django.test import SimpleTestCase
-from ..utils import render, setup
+from ..utils import setup
class EscapejsTests(SimpleTestCase):
@setup({'escapejs01': '{{ a|escapejs }}'})
def test_escapejs01(self):
- output = render('escapejs01', {'a': 'testing\r\njavascript \'string" escaping'})
+ output = self.engine.render_to_string('escapejs01', {'a': 'testing\r\njavascript \'string" escaping'})
self.assertEqual(output, 'testing\\u000D\\u000Ajavascript '
'\\u0027string\\u0022 \\u003Cb\\u003E'
'escaping\\u003C/b\\u003E')
@setup({'escapejs02': '{% autoescape off %}{{ a|escapejs }}{% endautoescape %}'})
def test_escapejs02(self):
- output = render('escapejs02', {'a': 'testing\r\njavascript \'string" escaping'})
+ output = self.engine.render_to_string('escapejs02', {'a': 'testing\r\njavascript \'string" escaping'})
self.assertEqual(output, 'testing\\u000D\\u000Ajavascript '
'\\u0027string\\u0022 \\u003Cb\\u003E'
'escaping\\u003C/b\\u003E')
diff --git a/tests/template_tests/filter_tests/test_first.py b/tests/template_tests/filter_tests/test_first.py
index c7361dbd12b..efba48f8709 100644
--- a/tests/template_tests/filter_tests/test_first.py
+++ b/tests/template_tests/filter_tests/test_first.py
@@ -2,19 +2,19 @@ from django.template.defaultfilters import first
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
-from ..utils import render, setup
+from ..utils import setup
class FirstTests(SimpleTestCase):
@setup({'first01': '{{ a|first }} {{ b|first }}'})
def test_first01(self):
- output = render('first01', {"a": ["a&b", "x"], "b": [mark_safe("a&b"), "x"]})
+ output = self.engine.render_to_string('first01', {"a": ["a&b", "x"], "b": [mark_safe("a&b"), "x"]})
self.assertEqual(output, "a&b a&b")
@setup({'first02': '{% autoescape off %}{{ a|first }} {{ b|first }}{% endautoescape %}'})
def test_first02(self):
- output = render('first02', {"a": ["a&b", "x"], "b": [mark_safe("a&b"), "x"]})
+ output = self.engine.render_to_string('first02', {"a": ["a&b", "x"], "b": [mark_safe("a&b"), "x"]})
self.assertEqual(output, "a&b a&b")
diff --git a/tests/template_tests/filter_tests/test_floatformat.py b/tests/template_tests/filter_tests/test_floatformat.py
index 466984b006e..5fe35ee3780 100644
--- a/tests/template_tests/filter_tests/test_floatformat.py
+++ b/tests/template_tests/filter_tests/test_floatformat.py
@@ -9,7 +9,7 @@ from django.test import SimpleTestCase
from django.utils import six
from django.utils.safestring import mark_safe
-from ..utils import render, setup
+from ..utils import setup
class FloatformatTests(SimpleTestCase):
@@ -17,12 +17,12 @@ class FloatformatTests(SimpleTestCase):
@setup({'floatformat01':
'{% autoescape off %}{{ a|floatformat }} {{ b|floatformat }}{% endautoescape %}'})
def test_floatformat01(self):
- output = render('floatformat01', {"a": "1.42", "b": mark_safe("1.42")})
+ output = self.engine.render_to_string('floatformat01', {"a": "1.42", "b": mark_safe("1.42")})
self.assertEqual(output, "1.4 1.4")
@setup({'floatformat02': '{{ a|floatformat }} {{ b|floatformat }}'})
def test_floatformat02(self):
- output = render('floatformat02', {"a": "1.42", "b": mark_safe("1.42")})
+ output = self.engine.render_to_string('floatformat02', {"a": "1.42", "b": mark_safe("1.42")})
self.assertEqual(output, "1.4 1.4")
diff --git a/tests/template_tests/filter_tests/test_force_escape.py b/tests/template_tests/filter_tests/test_force_escape.py
index b231d8e3741..875ecb0ad9e 100644
--- a/tests/template_tests/filter_tests/test_force_escape.py
+++ b/tests/template_tests/filter_tests/test_force_escape.py
@@ -5,7 +5,7 @@ from django.template.defaultfilters import force_escape
from django.test import SimpleTestCase
from django.utils.safestring import SafeData
-from ..utils import render, setup
+from ..utils import setup
class ForceEscapeTests(SimpleTestCase):
@@ -16,44 +16,44 @@ class ForceEscapeTests(SimpleTestCase):
@setup({'force-escape01': '{% autoescape off %}{{ a|force_escape }}{% endautoescape %}'})
def test_force_escape01(self):
- output = render('force-escape01', {"a": "x&y"})
+ output = self.engine.render_to_string('force-escape01', {"a": "x&y"})
self.assertEqual(output, "x&y")
@setup({'force-escape02': '{{ a|force_escape }}'})
def test_force_escape02(self):
- output = render('force-escape02', {"a": "x&y"})
+ output = self.engine.render_to_string('force-escape02', {"a": "x&y"})
self.assertEqual(output, "x&y")
@setup({'force-escape03': '{% autoescape off %}{{ a|force_escape|force_escape }}{% endautoescape %}'})
def test_force_escape03(self):
- output = render('force-escape03', {"a": "x&y"})
+ output = self.engine.render_to_string('force-escape03', {"a": "x&y"})
self.assertEqual(output, "x&y")
@setup({'force-escape04': '{{ a|force_escape|force_escape }}'})
def test_force_escape04(self):
- output = render('force-escape04', {"a": "x&y"})
+ output = self.engine.render_to_string('force-escape04', {"a": "x&y"})
self.assertEqual(output, "x&y")
# Because the result of force_escape is "safe", an additional
# escape filter has no effect.
@setup({'force-escape05': '{% autoescape off %}{{ a|force_escape|escape }}{% endautoescape %}'})
def test_force_escape05(self):
- output = render('force-escape05', {"a": "x&y"})
+ output = self.engine.render_to_string('force-escape05', {"a": "x&y"})
self.assertEqual(output, "x&y")
@setup({'force-escape06': '{{ a|force_escape|escape }}'})
def test_force_escape06(self):
- output = render('force-escape06', {"a": "x&y"})
+ output = self.engine.render_to_string('force-escape06', {"a": "x&y"})
self.assertEqual(output, "x&y")
@setup({'force-escape07': '{% autoescape off %}{{ a|escape|force_escape }}{% endautoescape %}'})
def test_force_escape07(self):
- output = render('force-escape07', {"a": "x&y"})
+ output = self.engine.render_to_string('force-escape07', {"a": "x&y"})
self.assertEqual(output, "x&y")
@setup({'force-escape08': '{{ a|escape|force_escape }}'})
def test_force_escape08(self):
- output = render('force-escape08', {"a": "x&y"})
+ output = self.engine.render_to_string('force-escape08', {"a": "x&y"})
self.assertEqual(output, "x&y")
diff --git a/tests/template_tests/filter_tests/test_iriencode.py b/tests/template_tests/filter_tests/test_iriencode.py
index c44c54eb6a2..837d6aa0f72 100644
--- a/tests/template_tests/filter_tests/test_iriencode.py
+++ b/tests/template_tests/filter_tests/test_iriencode.py
@@ -5,7 +5,7 @@ from django.template.defaultfilters import iriencode, urlencode
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
-from ..utils import render, setup
+from ..utils import setup
class IriencodeTests(SimpleTestCase):
@@ -15,22 +15,22 @@ class IriencodeTests(SimpleTestCase):
@setup({'iriencode01': '{{ url|iriencode }}'})
def test_iriencode01(self):
- output = render('iriencode01', {'url': '?test=1&me=2'})
+ output = self.engine.render_to_string('iriencode01', {'url': '?test=1&me=2'})
self.assertEqual(output, '?test=1&me=2')
@setup({'iriencode02': '{% autoescape off %}{{ url|iriencode }}{% endautoescape %}'})
def test_iriencode02(self):
- output = render('iriencode02', {'url': '?test=1&me=2'})
+ output = self.engine.render_to_string('iriencode02', {'url': '?test=1&me=2'})
self.assertEqual(output, '?test=1&me=2')
@setup({'iriencode03': '{{ url|iriencode }}'})
def test_iriencode03(self):
- output = render('iriencode03', {'url': mark_safe('?test=1&me=2')})
+ output = self.engine.render_to_string('iriencode03', {'url': mark_safe('?test=1&me=2')})
self.assertEqual(output, '?test=1&me=2')
@setup({'iriencode04': '{% autoescape off %}{{ url|iriencode }}{% endautoescape %}'})
def test_iriencode04(self):
- output = render('iriencode04', {'url': mark_safe('?test=1&me=2')})
+ output = self.engine.render_to_string('iriencode04', {'url': mark_safe('?test=1&me=2')})
self.assertEqual(output, '?test=1&me=2')
diff --git a/tests/template_tests/filter_tests/test_join.py b/tests/template_tests/filter_tests/test_join.py
index 87a00d6d182..1a5193824b4 100644
--- a/tests/template_tests/filter_tests/test_join.py
+++ b/tests/template_tests/filter_tests/test_join.py
@@ -2,51 +2,51 @@ from django.template.defaultfilters import join
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
-from ..utils import render, setup
+from ..utils import setup
class JoinTests(SimpleTestCase):
@setup({'join01': '{{ a|join:", " }}'})
def test_join01(self):
- output = render('join01', {'a': ['alpha', 'beta & me']})
+ output = self.engine.render_to_string('join01', {'a': ['alpha', 'beta & me']})
self.assertEqual(output, 'alpha, beta & me')
@setup({'join02': '{% autoescape off %}{{ a|join:", " }}{% endautoescape %}'})
def test_join02(self):
- output = render('join02', {'a': ['alpha', 'beta & me']})
+ output = self.engine.render_to_string('join02', {'a': ['alpha', 'beta & me']})
self.assertEqual(output, 'alpha, beta & me')
@setup({'join03': '{{ a|join:" & " }}'})
def test_join03(self):
- output = render('join03', {'a': ['alpha', 'beta & me']})
+ output = self.engine.render_to_string('join03', {'a': ['alpha', 'beta & me']})
self.assertEqual(output, 'alpha & beta & me')
@setup({'join04': '{% autoescape off %}{{ a|join:" & " }}{% endautoescape %}'})
def test_join04(self):
- output = render('join04', {'a': ['alpha', 'beta & me']})
+ output = self.engine.render_to_string('join04', {'a': ['alpha', 'beta & me']})
self.assertEqual(output, 'alpha & beta & me')
# #11377 Test that joining with unsafe joiners doesn't result in
# unsafe strings
@setup({'join05': '{{ a|join:var }}'})
def test_join05(self):
- output = render('join05', {'a': ['alpha', 'beta & me'], 'var': ' & '})
+ output = self.engine.render_to_string('join05', {'a': ['alpha', 'beta & me'], 'var': ' & '})
self.assertEqual(output, 'alpha & beta & me')
@setup({'join06': '{{ a|join:var }}'})
def test_join06(self):
- output = render('join06', {'a': ['alpha', 'beta & me'], 'var': mark_safe(' & ')})
+ output = self.engine.render_to_string('join06', {'a': ['alpha', 'beta & me'], 'var': mark_safe(' & ')})
self.assertEqual(output, 'alpha & beta & me')
@setup({'join07': '{{ a|join:var|lower }}'})
def test_join07(self):
- output = render('join07', {'a': ['Alpha', 'Beta & me'], 'var': ' & '})
+ output = self.engine.render_to_string('join07', {'a': ['Alpha', 'Beta & me'], 'var': ' & '})
self.assertEqual(output, 'alpha & beta & me')
@setup({'join08': '{{ a|join:var|lower }}'})
def test_join08(self):
- output = render('join08', {'a': ['Alpha', 'Beta & me'], 'var': mark_safe(' & ')})
+ output = self.engine.render_to_string('join08', {'a': ['Alpha', 'Beta & me'], 'var': mark_safe(' & ')})
self.assertEqual(output, 'alpha & beta & me')
diff --git a/tests/template_tests/filter_tests/test_last.py b/tests/template_tests/filter_tests/test_last.py
index 1dcee663e91..29c558fa26c 100644
--- a/tests/template_tests/filter_tests/test_last.py
+++ b/tests/template_tests/filter_tests/test_last.py
@@ -1,17 +1,17 @@
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
-from ..utils import render, setup
+from ..utils import setup
class LastTests(SimpleTestCase):
@setup({'last01': '{{ a|last }} {{ b|last }}'})
def test_last01(self):
- output = render('last01', {"a": ["x", "a&b"], "b": ["x", mark_safe("a&b")]})
+ output = self.engine.render_to_string('last01', {"a": ["x", "a&b"], "b": ["x", mark_safe("a&b")]})
self.assertEqual(output, "a&b a&b")
@setup({'last02': '{% autoescape off %}{{ a|last }} {{ b|last }}{% endautoescape %}'})
def test_last02(self):
- output = render('last02', {"a": ["x", "a&b"], "b": ["x", mark_safe("a&b")]})
+ output = self.engine.render_to_string('last02', {"a": ["x", "a&b"], "b": ["x", mark_safe("a&b")]})
self.assertEqual(output, "a&b a&b")
diff --git a/tests/template_tests/filter_tests/test_length.py b/tests/template_tests/filter_tests/test_length.py
index cd605aa7856..9ea90a12349 100644
--- a/tests/template_tests/filter_tests/test_length.py
+++ b/tests/template_tests/filter_tests/test_length.py
@@ -2,45 +2,45 @@ from django.template.defaultfilters import length
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
-from ..utils import render, setup
+from ..utils import setup
class LengthTests(SimpleTestCase):
@setup({'length01': '{{ list|length }}'})
def test_length01(self):
- output = render('length01', {'list': ['4', None, True, {}]})
+ output = self.engine.render_to_string('length01', {'list': ['4', None, True, {}]})
self.assertEqual(output, '4')
@setup({'length02': '{{ list|length }}'})
def test_length02(self):
- output = render('length02', {'list': []})
+ output = self.engine.render_to_string('length02', {'list': []})
self.assertEqual(output, '0')
@setup({'length03': '{{ string|length }}'})
def test_length03(self):
- output = render('length03', {'string': ''})
+ output = self.engine.render_to_string('length03', {'string': ''})
self.assertEqual(output, '0')
@setup({'length04': '{{ string|length }}'})
def test_length04(self):
- output = render('length04', {'string': 'django'})
+ output = self.engine.render_to_string('length04', {'string': 'django'})
self.assertEqual(output, '6')
@setup({'length05': '{% if string|length == 6 %}Pass{% endif %}'})
def test_length05(self):
- output = render('length05', {'string': mark_safe('django')})
+ output = self.engine.render_to_string('length05', {'string': mark_safe('django')})
self.assertEqual(output, 'Pass')
# Invalid uses that should fail silently.
@setup({'length06': '{{ int|length }}'})
def test_length06(self):
- output = render('length06', {'int': 7})
+ output = self.engine.render_to_string('length06', {'int': 7})
self.assertEqual(output, '0')
@setup({'length07': '{{ None|length }}'})
def test_length07(self):
- output = render('length07', {'None': None})
+ output = self.engine.render_to_string('length07', {'None': None})
self.assertEqual(output, '0')
diff --git a/tests/template_tests/filter_tests/test_length_is.py b/tests/template_tests/filter_tests/test_length_is.py
index d0f547a3c29..9a67a866d4f 100644
--- a/tests/template_tests/filter_tests/test_length_is.py
+++ b/tests/template_tests/filter_tests/test_length_is.py
@@ -1,66 +1,66 @@
from django.template.defaultfilters import length_is
from django.test import SimpleTestCase
-from ..utils import render, setup
+from ..utils import setup
class LengthIsTests(SimpleTestCase):
@setup({'length_is01': '{% if some_list|length_is:"4" %}Four{% endif %}'})
def test_length_is01(self):
- output = render('length_is01', {'some_list': ['4', None, True, {}]})
+ output = self.engine.render_to_string('length_is01', {'some_list': ['4', None, True, {}]})
self.assertEqual(output, 'Four')
@setup({'length_is02': '{% if some_list|length_is:"4" %}Four{% else %}Not Four{% endif %}'})
def test_length_is02(self):
- output = render('length_is02', {'some_list': ['4', None, True, {}, 17]})
+ output = self.engine.render_to_string('length_is02', {'some_list': ['4', None, True, {}, 17]})
self.assertEqual(output, 'Not Four')
@setup({'length_is03': '{% if mystring|length_is:"4" %}Four{% endif %}'})
def test_length_is03(self):
- output = render('length_is03', {'mystring': 'word'})
+ output = self.engine.render_to_string('length_is03', {'mystring': 'word'})
self.assertEqual(output, 'Four')
@setup({'length_is04': '{% if mystring|length_is:"4" %}Four{% else %}Not Four{% endif %}'})
def test_length_is04(self):
- output = render('length_is04', {'mystring': 'Python'})
+ output = self.engine.render_to_string('length_is04', {'mystring': 'Python'})
self.assertEqual(output, 'Not Four')
@setup({'length_is05': '{% if mystring|length_is:"4" %}Four{% else %}Not Four{% endif %}'})
def test_length_is05(self):
- output = render('length_is05', {'mystring': ''})
+ output = self.engine.render_to_string('length_is05', {'mystring': ''})
self.assertEqual(output, 'Not Four')
@setup({'length_is06': '{% with var|length as my_length %}{{ my_length }}{% endwith %}'})
def test_length_is06(self):
- output = render('length_is06', {'var': 'django'})
+ output = self.engine.render_to_string('length_is06', {'var': 'django'})
self.assertEqual(output, '6')
# Boolean return value from length_is should not be coerced to a string
@setup({'length_is07': '{% if "X"|length_is:0 %}Length is 0{% else %}Length not 0{% endif %}'})
def test_length_is07(self):
- output = render('length_is07', {})
+ output = self.engine.render_to_string('length_is07', {})
self.assertEqual(output, 'Length not 0')
@setup({'length_is08': '{% if "X"|length_is:1 %}Length is 1{% else %}Length not 1{% endif %}'})
def test_length_is08(self):
- output = render('length_is08', {})
+ output = self.engine.render_to_string('length_is08', {})
self.assertEqual(output, 'Length is 1')
# Invalid uses that should fail silently.
@setup({'length_is09': '{{ var|length_is:"fish" }}'})
def test_length_is09(self):
- output = render('length_is09', {'var': 'django'})
+ output = self.engine.render_to_string('length_is09', {'var': 'django'})
self.assertEqual(output, '')
@setup({'length_is10': '{{ int|length_is:"1" }}'})
def test_length_is10(self):
- output = render('length_is10', {'int': 7})
+ output = self.engine.render_to_string('length_is10', {'int': 7})
self.assertEqual(output, '')
@setup({'length_is11': '{{ none|length_is:"1" }}'})
def test_length_is11(self):
- output = render('length_is11', {'none': None})
+ output = self.engine.render_to_string('length_is11', {'none': None})
self.assertEqual(output, '')
diff --git a/tests/template_tests/filter_tests/test_linebreaks.py b/tests/template_tests/filter_tests/test_linebreaks.py
index 852617ba7fd..041bfb76170 100644
--- a/tests/template_tests/filter_tests/test_linebreaks.py
+++ b/tests/template_tests/filter_tests/test_linebreaks.py
@@ -2,7 +2,7 @@ from django.template.defaultfilters import linebreaks_filter
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
-from ..utils import render, setup
+from ..utils import setup
class LinebreaksTests(SimpleTestCase):
@@ -13,13 +13,13 @@ class LinebreaksTests(SimpleTestCase):
@setup({'linebreaks01': '{{ a|linebreaks }} {{ b|linebreaks }}'})
def test_linebreaks01(self):
- output = render('linebreaks01', {"a": "x&\ny", "b": mark_safe("x&\ny")})
+ output = self.engine.render_to_string('linebreaks01', {"a": "x&\ny", "b": mark_safe("x&\ny")})
self.assertEqual(output, " x& x& x& x& y y
y
y
y
y
y x&
y")
@setup({'linebreaksbr02':
'{% autoescape off %}{{ a|linebreaksbr }} {{ b|linebreaksbr }}{% endautoescape %}'})
def test_linebreaksbr02(self):
- output = render('linebreaksbr02', {"a": "x&\ny", "b": mark_safe("x&\ny")})
+ output = self.engine.render_to_string('linebreaksbr02', {"a": "x&\ny", "b": mark_safe("x&\ny")})
self.assertEqual(output, "x&
y x&
y")
diff --git a/tests/template_tests/filter_tests/test_linenumbers.py b/tests/template_tests/filter_tests/test_linenumbers.py
index d7e93d94290..d8c18b84d58 100644
--- a/tests/template_tests/filter_tests/test_linenumbers.py
+++ b/tests/template_tests/filter_tests/test_linenumbers.py
@@ -2,7 +2,7 @@ from django.template.defaultfilters import linenumbers
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
-from ..utils import render, setup
+from ..utils import setup
class LinenumbersTests(SimpleTestCase):
@@ -13,7 +13,7 @@ class LinenumbersTests(SimpleTestCase):
@setup({'linenumbers01': '{{ a|linenumbers }} {{ b|linenumbers }}'})
def test_linenumbers01(self):
- output = render(
+ output = self.engine.render_to_string(
'linenumbers01',
{'a': 'one\n
y
', @@ -20,7 +20,7 @@ class StriptagsTests(SimpleTestCase): @setup({'striptags02': '{% autoescape off %}{{ a|striptags }} {{ b|striptags }}{% endautoescape %}'}) def test_striptags02(self): - output = render( + output = self.engine.render_to_string( 'striptags02', { 'a': 'xy
', diff --git a/tests/template_tests/filter_tests/test_time.py b/tests/template_tests/filter_tests/test_time.py index 5f6373e4f61..e2b47b45b44 100644 --- a/tests/template_tests/filter_tests/test_time.py +++ b/tests/template_tests/filter_tests/test_time.py @@ -5,7 +5,7 @@ from django.test import SimpleTestCase from django.utils import timezone from .timezone_utils import TimezoneTestCase -from ..utils import render, setup +from ..utils import setup class TimeTests(TimezoneTestCase): @@ -15,32 +15,32 @@ class TimeTests(TimezoneTestCase): @setup({'time01': '{{ dt|time:"e:O:T:Z" }}'}) def test_time01(self): - output = render('time01', {'dt': self.now_tz_i}) + output = self.engine.render_to_string('time01', {'dt': self.now_tz_i}) self.assertEqual(output, '+0315:+0315:+0315:11700') @setup({'time02': '{{ dt|time:"e:T" }}'}) def test_time02(self): - output = render('time02', {'dt': self.now}) + output = self.engine.render_to_string('time02', {'dt': self.now}) self.assertEqual(output, ':' + self.now_tz.tzinfo.tzname(self.now_tz)) @setup({'time03': '{{ t|time:"P:e:O:T:Z" }}'}) def test_time03(self): - output = render('time03', {'t': time(4, 0, tzinfo=timezone.get_fixed_timezone(30))}) + output = self.engine.render_to_string('time03', {'t': time(4, 0, tzinfo=timezone.get_fixed_timezone(30))}) self.assertEqual(output, '4 a.m.::::') @setup({'time04': '{{ t|time:"P:e:O:T:Z" }}'}) def test_time04(self): - output = render('time04', {'t': time(4, 0)}) + output = self.engine.render_to_string('time04', {'t': time(4, 0)}) self.assertEqual(output, '4 a.m.::::') @setup({'time05': '{{ d|time:"P:e:O:T:Z" }}'}) def test_time05(self): - output = render('time05', {'d': self.today}) + output = self.engine.render_to_string('time05', {'d': self.today}) self.assertEqual(output, '') @setup({'time06': '{{ obj|time:"P:e:O:T:Z" }}'}) def test_time06(self): - output = render('time06', {'obj': 'non-datetime-value'}) + output = self.engine.render_to_string('time06', {'obj': 'non-datetime-value'}) self.assertEqual(output, '') diff --git a/tests/template_tests/filter_tests/test_timesince.py b/tests/template_tests/filter_tests/test_timesince.py index 12349e6d502..e10e86e921b 100644 --- a/tests/template_tests/filter_tests/test_timesince.py +++ b/tests/template_tests/filter_tests/test_timesince.py @@ -7,7 +7,7 @@ from django.test import SimpleTestCase from django.test.utils import requires_tz_support from .timezone_utils import TimezoneTestCase -from ..utils import render, setup +from ..utils import setup class TimesinceTests(TimezoneTestCase): @@ -18,23 +18,23 @@ class TimesinceTests(TimezoneTestCase): # Default compare with datetime.now() @setup({'timesince01': '{{ a|timesince }}'}) def test_timesince01(self): - output = render('timesince01', {'a': datetime.now() + timedelta(minutes=-1, seconds=-10)}) + output = self.engine.render_to_string('timesince01', {'a': datetime.now() + timedelta(minutes=-1, seconds=-10)}) self.assertEqual(output, '1\xa0minute') @setup({'timesince02': '{{ a|timesince }}'}) def test_timesince02(self): - output = render('timesince02', {'a': datetime.now() - timedelta(days=1, minutes=1)}) + output = self.engine.render_to_string('timesince02', {'a': datetime.now() - timedelta(days=1, minutes=1)}) self.assertEqual(output, '1\xa0day') @setup({'timesince03': '{{ a|timesince }}'}) def test_timesince03(self): - output = render('timesince03', {'a': datetime.now() - timedelta(hours=1, minutes=25, seconds=10)}) + output = self.engine.render_to_string('timesince03', {'a': datetime.now() - timedelta(hours=1, minutes=25, seconds=10)}) self.assertEqual(output, '1\xa0hour, 25\xa0minutes') # Compare to a given parameter @setup({'timesince04': '{{ a|timesince:b }}'}) def test_timesince04(self): - output = render( + output = self.engine.render_to_string( 'timesince04', {'a': self.now - timedelta(days=2), 'b': self.now - timedelta(days=1)}, ) @@ -42,7 +42,7 @@ class TimesinceTests(TimezoneTestCase): @setup({'timesince05': '{{ a|timesince:b }}'}) def test_timesince05(self): - output = render( + output = self.engine.render_to_string( 'timesince05', {'a': self.now - timedelta(days=2, minutes=1), 'b': self.now - timedelta(days=2)}, ) @@ -51,72 +51,72 @@ class TimesinceTests(TimezoneTestCase): # Check that timezone is respected @setup({'timesince06': '{{ a|timesince:b }}'}) def test_timesince06(self): - output = render('timesince06', {'a': self.now_tz - timedelta(hours=8), 'b': self.now_tz}) + output = self.engine.render_to_string('timesince06', {'a': self.now_tz - timedelta(hours=8), 'b': self.now_tz}) self.assertEqual(output, '8\xa0hours') # Tests for #7443 @setup({'timesince07': '{{ earlier|timesince }}'}) def test_timesince07(self): - output = render('timesince07', {'earlier': self.now - timedelta(days=7)}) + output = self.engine.render_to_string('timesince07', {'earlier': self.now - timedelta(days=7)}) self.assertEqual(output, '1\xa0week') @setup({'timesince08': '{{ earlier|timesince:now }}'}) def test_timesince08(self): - output = render('timesince08', {'now': self.now, 'earlier': self.now - timedelta(days=7)}) + output = self.engine.render_to_string('timesince08', {'now': self.now, 'earlier': self.now - timedelta(days=7)}) self.assertEqual(output, '1\xa0week') @setup({'timesince09': '{{ later|timesince }}'}) def test_timesince09(self): - output = render('timesince09', {'later': self.now + timedelta(days=7)}) + output = self.engine.render_to_string('timesince09', {'later': self.now + timedelta(days=7)}) self.assertEqual(output, '0\xa0minutes') @setup({'timesince10': '{{ later|timesince:now }}'}) def test_timesince10(self): - output = render('timesince10', {'now': self.now, 'later': self.now + timedelta(days=7)}) + output = self.engine.render_to_string('timesince10', {'now': self.now, 'later': self.now + timedelta(days=7)}) self.assertEqual(output, '0\xa0minutes') # Ensures that differing timezones are calculated correctly. @setup({'timesince11': '{{ a|timesince }}'}) def test_timesince11(self): - output = render('timesince11', {'a': self.now}) + output = self.engine.render_to_string('timesince11', {'a': self.now}) self.assertEqual(output, '0\xa0minutes') @requires_tz_support @setup({'timesince12': '{{ a|timesince }}'}) def test_timesince12(self): - output = render('timesince12', {'a': self.now_tz}) + output = self.engine.render_to_string('timesince12', {'a': self.now_tz}) self.assertEqual(output, '0\xa0minutes') @requires_tz_support @setup({'timesince13': '{{ a|timesince }}'}) def test_timesince13(self): - output = render('timesince13', {'a': self.now_tz_i}) + output = self.engine.render_to_string('timesince13', {'a': self.now_tz_i}) self.assertEqual(output, '0\xa0minutes') @setup({'timesince14': '{{ a|timesince:b }}'}) def test_timesince14(self): - output = render('timesince14', {'a': self.now_tz, 'b': self.now_tz_i}) + output = self.engine.render_to_string('timesince14', {'a': self.now_tz, 'b': self.now_tz_i}) self.assertEqual(output, '0\xa0minutes') @setup({'timesince15': '{{ a|timesince:b }}'}) def test_timesince15(self): - output = render('timesince15', {'a': self.now, 'b': self.now_tz_i}) + output = self.engine.render_to_string('timesince15', {'a': self.now, 'b': self.now_tz_i}) self.assertEqual(output, '') @setup({'timesince16': '{{ a|timesince:b }}'}) def test_timesince16(self): - output = render('timesince16', {'a': self.now_tz_i, 'b': self.now}) + output = self.engine.render_to_string('timesince16', {'a': self.now_tz_i, 'b': self.now}) self.assertEqual(output, '') # Tests for #9065 (two date objects). @setup({'timesince17': '{{ a|timesince:b }}'}) def test_timesince17(self): - output = render('timesince17', {'a': self.today, 'b': self.today}) + output = self.engine.render_to_string('timesince17', {'a': self.today, 'b': self.today}) self.assertEqual(output, '0\xa0minutes') @setup({'timesince18': '{{ a|timesince:b }}'}) def test_timesince18(self): - output = render('timesince18', {'a': self.today, 'b': self.today + timedelta(hours=24)}) + output = self.engine.render_to_string('timesince18', {'a': self.today, 'b': self.today + timedelta(hours=24)}) self.assertEqual(output, '1\xa0day') diff --git a/tests/template_tests/filter_tests/test_timeuntil.py b/tests/template_tests/filter_tests/test_timeuntil.py index a723b34e5e2..822a7ea9eb7 100644 --- a/tests/template_tests/filter_tests/test_timeuntil.py +++ b/tests/template_tests/filter_tests/test_timeuntil.py @@ -7,7 +7,7 @@ from django.test import SimpleTestCase from django.test.utils import requires_tz_support from .timezone_utils import TimezoneTestCase -from ..utils import render, setup +from ..utils import setup class TimeuntilTests(TimezoneTestCase): @@ -15,23 +15,23 @@ class TimeuntilTests(TimezoneTestCase): # Default compare with datetime.now() @setup({'timeuntil01': '{{ a|timeuntil }}'}) def test_timeuntil01(self): - output = render('timeuntil01', {'a': datetime.now() + timedelta(minutes=2, seconds=10)}) + output = self.engine.render_to_string('timeuntil01', {'a': datetime.now() + timedelta(minutes=2, seconds=10)}) self.assertEqual(output, '2\xa0minutes') @setup({'timeuntil02': '{{ a|timeuntil }}'}) def test_timeuntil02(self): - output = render('timeuntil02', {'a': (datetime.now() + timedelta(days=1, seconds=10))}) + output = self.engine.render_to_string('timeuntil02', {'a': (datetime.now() + timedelta(days=1, seconds=10))}) self.assertEqual(output, '1\xa0day') @setup({'timeuntil03': '{{ a|timeuntil }}'}) def test_timeuntil03(self): - output = render('timeuntil03', {'a': (datetime.now() + timedelta(hours=8, minutes=10, seconds=10))}) + output = self.engine.render_to_string('timeuntil03', {'a': (datetime.now() + timedelta(hours=8, minutes=10, seconds=10))}) self.assertEqual(output, '8\xa0hours, 10\xa0minutes') # Compare to a given parameter @setup({'timeuntil04': '{{ a|timeuntil:b }}'}) def test_timeuntil04(self): - output = render( + output = self.engine.render_to_string( 'timeuntil04', {'a': self.now - timedelta(days=1), 'b': self.now - timedelta(days=2)}, ) @@ -39,7 +39,7 @@ class TimeuntilTests(TimezoneTestCase): @setup({'timeuntil05': '{{ a|timeuntil:b }}'}) def test_timeuntil05(self): - output = render( + output = self.engine.render_to_string( 'timeuntil05', {'a': self.now - timedelta(days=2), 'b': self.now - timedelta(days=2, minutes=1)}, ) @@ -48,51 +48,51 @@ class TimeuntilTests(TimezoneTestCase): # Regression for #7443 @setup({'timeuntil06': '{{ earlier|timeuntil }}'}) def test_timeuntil06(self): - output = render('timeuntil06', {'earlier': self.now - timedelta(days=7)}) + output = self.engine.render_to_string('timeuntil06', {'earlier': self.now - timedelta(days=7)}) self.assertEqual(output, '0\xa0minutes') @setup({'timeuntil07': '{{ earlier|timeuntil:now }}'}) def test_timeuntil07(self): - output = render('timeuntil07', {'now': self.now, 'earlier': self.now - timedelta(days=7)}) + output = self.engine.render_to_string('timeuntil07', {'now': self.now, 'earlier': self.now - timedelta(days=7)}) self.assertEqual(output, '0\xa0minutes') @setup({'timeuntil08': '{{ later|timeuntil }}'}) def test_timeuntil08(self): - output = render('timeuntil08', {'later': self.now + timedelta(days=7, hours=1)}) + output = self.engine.render_to_string('timeuntil08', {'later': self.now + timedelta(days=7, hours=1)}) self.assertEqual(output, '1\xa0week') @setup({'timeuntil09': '{{ later|timeuntil:now }}'}) def test_timeuntil09(self): - output = render('timeuntil09', {'now': self.now, 'later': self.now + timedelta(days=7)}) + output = self.engine.render_to_string('timeuntil09', {'now': self.now, 'later': self.now + timedelta(days=7)}) self.assertEqual(output, '1\xa0week') # Ensures that differing timezones are calculated correctly. @requires_tz_support @setup({'timeuntil10': '{{ a|timeuntil }}'}) def test_timeuntil10(self): - output = render('timeuntil10', {'a': self.now_tz}) + output = self.engine.render_to_string('timeuntil10', {'a': self.now_tz}) self.assertEqual(output, '0\xa0minutes') @requires_tz_support @setup({'timeuntil11': '{{ a|timeuntil }}'}) def test_timeuntil11(self): - output = render('timeuntil11', {'a': self.now_tz_i}) + output = self.engine.render_to_string('timeuntil11', {'a': self.now_tz_i}) self.assertEqual(output, '0\xa0minutes') @setup({'timeuntil12': '{{ a|timeuntil:b }}'}) def test_timeuntil12(self): - output = render('timeuntil12', {'a': self.now_tz_i, 'b': self.now_tz}) + output = self.engine.render_to_string('timeuntil12', {'a': self.now_tz_i, 'b': self.now_tz}) self.assertEqual(output, '0\xa0minutes') # Regression for #9065 (two date objects). @setup({'timeuntil13': '{{ a|timeuntil:b }}'}) def test_timeuntil13(self): - output = render('timeuntil13', {'a': self.today, 'b': self.today}) + output = self.engine.render_to_string('timeuntil13', {'a': self.today, 'b': self.today}) self.assertEqual(output, '0\xa0minutes') @setup({'timeuntil14': '{{ a|timeuntil:b }}'}) def test_timeuntil14(self): - output = render('timeuntil14', {'a': self.today, 'b': self.today - timedelta(hours=24)}) + output = self.engine.render_to_string('timeuntil14', {'a': self.today, 'b': self.today - timedelta(hours=24)}) self.assertEqual(output, '1\xa0day') diff --git a/tests/template_tests/filter_tests/test_title.py b/tests/template_tests/filter_tests/test_title.py index 67aa9107335..cf4d1033c63 100644 --- a/tests/template_tests/filter_tests/test_title.py +++ b/tests/template_tests/filter_tests/test_title.py @@ -4,19 +4,19 @@ from __future__ import unicode_literals from django.template.defaultfilters import title from django.test import SimpleTestCase -from ..utils import render, setup +from ..utils import setup class TitleTests(SimpleTestCase): @setup({'title1': '{{ a|title }}'}) def test_title1(self): - output = render('title1', {'a': 'JOE\'S CRAB SHACK'}) + output = self.engine.render_to_string('title1', {'a': 'JOE\'S CRAB SHACK'}) self.assertEqual(output, 'Joe's Crab Shack') @setup({'title2': '{{ a|title }}'}) def test_title2(self): - output = render('title2', {'a': '555 WEST 53RD STREET'}) + output = self.engine.render_to_string('title2', {'a': '555 WEST 53RD STREET'}) self.assertEqual(output, '555 West 53rd Street') diff --git a/tests/template_tests/filter_tests/test_truncatechars.py b/tests/template_tests/filter_tests/test_truncatechars.py index f31bf90269d..eea6f64a6ed 100644 --- a/tests/template_tests/filter_tests/test_truncatechars.py +++ b/tests/template_tests/filter_tests/test_truncatechars.py @@ -1,16 +1,16 @@ from django.test import SimpleTestCase -from ..utils import render, setup +from ..utils import setup class TruncatecharsTests(SimpleTestCase): @setup({'truncatechars01': '{{ a|truncatechars:5 }}'}) def test_truncatechars01(self): - output = render('truncatechars01', {'a': 'Testing, testing'}) + output = self.engine.render_to_string('truncatechars01', {'a': 'Testing, testing'}) self.assertEqual(output, 'Te...') @setup({'truncatechars02': '{{ a|truncatechars:7 }}'}) def test_truncatechars02(self): - output = render('truncatechars02', {'a': 'Testing'}) + output = self.engine.render_to_string('truncatechars02', {'a': 'Testing'}) self.assertEqual(output, 'Testing') diff --git a/tests/template_tests/filter_tests/test_truncatewords.py b/tests/template_tests/filter_tests/test_truncatewords.py index f9a3647085d..97b6013bb13 100644 --- a/tests/template_tests/filter_tests/test_truncatewords.py +++ b/tests/template_tests/filter_tests/test_truncatewords.py @@ -2,7 +2,7 @@ from django.template.defaultfilters import truncatewords from django.test import SimpleTestCase from django.utils.safestring import mark_safe -from ..utils import render, setup +from ..utils import setup class TruncatewordsTests(SimpleTestCase): @@ -10,12 +10,12 @@ class TruncatewordsTests(SimpleTestCase): @setup({'truncatewords01': '{% autoescape off %}{{ a|truncatewords:"2" }} {{ b|truncatewords:"2"}}{% endautoescape %}'}) def test_truncatewords01(self): - output = render('truncatewords01', {'a': 'alpha & bravo', 'b': mark_safe('alpha & bravo')}) + output = self.engine.render_to_string('truncatewords01', {'a': 'alpha & bravo', 'b': mark_safe('alpha & bravo')}) self.assertEqual(output, 'alpha & ... alpha & ...') @setup({'truncatewords02': '{{ a|truncatewords:"2" }} {{ b|truncatewords:"2"}}'}) def test_truncatewords02(self): - output = render('truncatewords02', {'a': 'alpha & bravo', 'b': mark_safe('alpha & bravo')}) + output = self.engine.render_to_string('truncatewords02', {'a': 'alpha & bravo', 'b': mark_safe('alpha & bravo')}) self.assertEqual(output, 'alpha & ... alpha & ...') diff --git a/tests/template_tests/filter_tests/test_unordered_list.py b/tests/template_tests/filter_tests/test_unordered_list.py index 8575551b084..97726a5a441 100644 --- a/tests/template_tests/filter_tests/test_unordered_list.py +++ b/tests/template_tests/filter_tests/test_unordered_list.py @@ -6,36 +6,36 @@ from django.utils.deprecation import RemovedInDjango20Warning from django.utils.encoding import python_2_unicode_compatible from django.utils.safestring import mark_safe -from ..utils import render, setup +from ..utils import setup class UnorderedListTests(SimpleTestCase): @setup({'unordered_list01': '{{ a|unordered_list }}'}) def test_unordered_list01(self): - output = render('unordered_list01', {'a': ['x>', ['