summaryrefslogtreecommitdiff
path: root/tests/template_tests/test_nodelist.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-06-20 07:37:43 -0400
committerTim Graham <timograham@gmail.com>2015-06-30 09:54:18 -0400
commit3b81dbe844b750c05bda6ae1ad15c889d1dc39e5 (patch)
treedcda32c9bb91cacf54a7b725c06fafcb61611bfb /tests/template_tests/test_nodelist.py
parentc31bf8cb54e591e244abc951896ef5e4a089f38d (diff)
Used %r in the TextNode repr to show newlines better.
Diffstat (limited to 'tests/template_tests/test_nodelist.py')
-rw-r--r--tests/template_tests/test_nodelist.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/template_tests/test_nodelist.py b/tests/template_tests/test_nodelist.py
index 3070c9d68a..46b48404dd 100644
--- a/tests/template_tests/test_nodelist.py
+++ b/tests/template_tests/test_nodelist.py
@@ -1,7 +1,8 @@
from unittest import TestCase
from django.template import Context, Engine
-from django.template.base import VariableNode
+from django.template.base import TextNode, VariableNode
+from django.utils import six
class NodelistTest(TestCase):
@@ -32,6 +33,21 @@ class NodelistTest(TestCase):
self.assertEqual(len(vars), 1)
+class TextNodeTest(TestCase):
+
+ def test_textnode_repr(self):
+ engine = Engine()
+ for temptext, reprtext in [
+ ("Hello, world!", "<TextNode: u'Hello, world!'>"),
+ ("One\ntwo.", "<TextNode: u'One\\ntwo.'>"),
+ ]:
+ template = engine.from_string(temptext)
+ texts = template.nodelist.get_nodes_by_type(TextNode)
+ if six.PY3:
+ reprtext = reprtext.replace("u'", "'")
+ self.assertEqual(repr(texts[0]), reprtext)
+
+
class ErrorIndexTest(TestCase):
"""
Checks whether index of error is calculated correctly in