diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-10-31 11:38:53 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-10-31 11:38:53 +0100 |
| commit | c0c1bb9e64d7e1cea50dc4818ffcf229b568578b (patch) | |
| tree | 8eb0c20045034a8cc99a3ab90d199261e6082401 /tests/template_tests | |
| parent | f2ddc439b1938acb6cae693bda9d8cf83a4583be (diff) | |
Avoided using private API get_template_from_string.
Diffstat (limited to 'tests/template_tests')
| -rw-r--r-- | tests/template_tests/test_nodelist.py | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/tests/template_tests/test_nodelist.py b/tests/template_tests/test_nodelist.py index 1c48d3f7ce..bce75aeecb 100644 --- a/tests/template_tests/test_nodelist.py +++ b/tests/template_tests/test_nodelist.py @@ -1,33 +1,28 @@ from unittest import TestCase -from django.template import VariableNode, Context -from django.template.loader import get_template_from_string +from django.template import Context, Template, VariableNode from django.test import override_settings class NodelistTest(TestCase): def test_for(self): - source = '{% for i in 1 %}{{ a }}{% endfor %}' - template = get_template_from_string(source) + template = Template('{% for i in 1 %}{{ a }}{% endfor %}') vars = template.nodelist.get_nodes_by_type(VariableNode) self.assertEqual(len(vars), 1) def test_if(self): - source = '{% if x %}{{ a }}{% endif %}' - template = get_template_from_string(source) + template = Template('{% if x %}{{ a }}{% endif %}') vars = template.nodelist.get_nodes_by_type(VariableNode) self.assertEqual(len(vars), 1) def test_ifequal(self): - source = '{% ifequal x y %}{{ a }}{% endifequal %}' - template = get_template_from_string(source) + template = Template('{% ifequal x y %}{{ a }}{% endifequal %}') vars = template.nodelist.get_nodes_by_type(VariableNode) self.assertEqual(len(vars), 1) def test_ifchanged(self): - source = '{% ifchanged x %}{{ a }}{% endifchanged %}' - template = get_template_from_string(source) + template = Template('{% ifchanged x %}{{ a }}{% endifchanged %}') vars = template.nodelist.get_nodes_by_type(VariableNode) self.assertEqual(len(vars), 1) @@ -51,7 +46,7 @@ class ErrorIndexTest(TestCase): 'five': 5, }) for source, expected_error_source_index in tests: - template = get_template_from_string(source) + template = Template(source) try: template.render(context) except (RuntimeError, TypeError) as e: |
