diff options
| author | Mads Jensen <mje@inducks.org> | 2017-02-04 11:43:14 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-02-04 11:29:39 -0500 |
| commit | ce69a421f6122efa7d14cc33a983553dd39b844c (patch) | |
| tree | 478c1217ac88e3e91c77801f2d7a8c71582b4b83 /tests/template_tests/syntax_tests | |
| parent | 2d899ce16bdbef1a015275237f0bfef4045fb6b2 (diff) | |
Added tests for various __repr__() methods.
Diffstat (limited to 'tests/template_tests/syntax_tests')
5 files changed, 41 insertions, 0 deletions
diff --git a/tests/template_tests/syntax_tests/i18n/test_trans.py b/tests/template_tests/syntax_tests/i18n/test_trans.py index fec9f1728d..ba5021a5d5 100644 --- a/tests/template_tests/syntax_tests/i18n/test_trans.py +++ b/tests/template_tests/syntax_tests/i18n/test_trans.py @@ -1,6 +1,7 @@ from threading import local from django.template import Context, Template, TemplateSyntaxError +from django.templatetags.l10n import LocalizeNode from django.test import SimpleTestCase, override_settings from django.utils import translation from django.utils.safestring import mark_safe @@ -203,3 +204,9 @@ class MultipleLocaleActivationTransTagTests(MultipleLocaleActivationTestCase): t = Template("{% load i18n %}{% trans 'No' %}") with translation.override('nl'): self.assertEqual(t.render(Context({})), 'Nee') + + +class LocalizeNodeTests(SimpleTestCase): + def test_repr(self): + node = LocalizeNode(nodelist=[], use_l10n=True) + self.assertEqual(repr(node), '<LocalizeNode>') diff --git a/tests/template_tests/syntax_tests/test_extends.py b/tests/template_tests/syntax_tests/test_extends.py index bc320a2fc2..5b0b8d1811 100644 --- a/tests/template_tests/syntax_tests/test_extends.py +++ b/tests/template_tests/syntax_tests/test_extends.py @@ -1,3 +1,6 @@ +from django.template import NodeList +from django.template.base import Node +from django.template.loader_tags import ExtendsNode from django.test import SimpleTestCase from ..utils import setup @@ -396,3 +399,13 @@ class InheritanceTests(SimpleTestCase): """ output = self.engine.render_to_string('inheritance42') self.assertEqual(output, '1234') + + +class ExtendsNodeTests(SimpleTestCase): + def test_extends_node_repr(self): + extends_node = ExtendsNode( + nodelist=NodeList([]), + parent_name=Node(), + template_dirs=[], + ) + self.assertEqual(repr(extends_node), '<ExtendsNode: extends None>') diff --git a/tests/template_tests/syntax_tests/test_if.py b/tests/template_tests/syntax_tests/test_if.py index 5ea57bf489..711f871af9 100644 --- a/tests/template_tests/syntax_tests/test_if.py +++ b/tests/template_tests/syntax_tests/test_if.py @@ -1,4 +1,5 @@ from django.template import TemplateSyntaxError +from django.template.defaulttags import IfNode from django.test import SimpleTestCase from ..utils import TestObj, setup @@ -599,3 +600,9 @@ class IfTagTests(SimpleTestCase): def test_if_is_not_both_variables_missing(self): output = self.engine.render_to_string('template', {}) self.assertEqual(output, 'no') + + +class IfNodeTests(SimpleTestCase): + def test_repr(self): + node = IfNode(conditions_nodelists=[]) + self.assertEqual(repr(node), '<IfNode>') diff --git a/tests/template_tests/syntax_tests/test_if_equal.py b/tests/template_tests/syntax_tests/test_if_equal.py index 6124608b08..82ddf557db 100644 --- a/tests/template_tests/syntax_tests/test_if_equal.py +++ b/tests/template_tests/syntax_tests/test_if_equal.py @@ -1,3 +1,4 @@ +from django.template.defaulttags import IfEqualNode from django.test import SimpleTestCase from ..utils import setup @@ -215,3 +216,9 @@ class IfNotEqualTagTests(SimpleTestCase): def test_ifnotequal04(self): output = self.engine.render_to_string('ifnotequal04', {'a': 1, 'b': 1}) self.assertEqual(output, 'no') + + +class IfEqualTests(SimpleTestCase): + def test_repr(self): + node = IfEqualNode(var1='a', var2='b', nodelist_true=[], nodelist_false=[], negate=False) + self.assertEqual(repr(node), '<IfEqualNode>') diff --git a/tests/template_tests/syntax_tests/test_with.py b/tests/template_tests/syntax_tests/test_with.py index ba1875af21..c1d501c94d 100644 --- a/tests/template_tests/syntax_tests/test_with.py +++ b/tests/template_tests/syntax_tests/test_with.py @@ -1,4 +1,5 @@ from django.template import TemplateSyntaxError +from django.template.defaulttags import WithNode from django.test import SimpleTestCase from ..utils import setup @@ -50,3 +51,9 @@ class WithTagTests(SimpleTestCase): def test_with_error02(self): with self.assertRaises(TemplateSyntaxError): self.engine.render_to_string('with-error02', {'dict': {'key': 50}}) + + +class WithNodeTests(SimpleTestCase): + def test_repr(self): + node = WithNode(nodelist=[], name='a', var='dict.key') + self.assertEqual(repr(node), '<WithNode>') |
