diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-12-07 09:43:10 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-12-28 16:23:01 +0100 |
| commit | 92a2d049a253fb499db88efb6cf6c9209f6f251c (patch) | |
| tree | bd3c913883b36f918f3c8ae7af942a8c8f50a23f /tests/template_tests/syntax_tests/test_with.py | |
| parent | b34b8a12b7f657f379c9e0e5ee7688bf36e242d2 (diff) | |
Isolated template tests from Django settings.
Diffstat (limited to 'tests/template_tests/syntax_tests/test_with.py')
| -rw-r--r-- | tests/template_tests/syntax_tests/test_with.py | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/tests/template_tests/syntax_tests/test_with.py b/tests/template_tests/syntax_tests/test_with.py index 571ea7f1c1..ba1875af21 100644 --- a/tests/template_tests/syntax_tests/test_with.py +++ b/tests/template_tests/syntax_tests/test_with.py @@ -1,28 +1,27 @@ -from django.conf import settings -from django.template.base import TemplateSyntaxError +from django.template import TemplateSyntaxError from django.test import SimpleTestCase -from ..utils import render, setup +from ..utils import setup class WithTagTests(SimpleTestCase): @setup({'with01': '{% with key=dict.key %}{{ key }}{% endwith %}'}) def test_with01(self): - output = render('with01', {'dict': {'key': 50}}) + output = self.engine.render_to_string('with01', {'dict': {'key': 50}}) self.assertEqual(output, '50') @setup({'legacywith01': '{% with dict.key as key %}{{ key }}{% endwith %}'}) def test_legacywith01(self): - output = render('legacywith01', {'dict': {'key': 50}}) + output = self.engine.render_to_string('legacywith01', {'dict': {'key': 50}}) self.assertEqual(output, '50') @setup({'with02': '{{ key }}{% with key=dict.key %}' '{{ key }}-{{ dict.key }}-{{ key }}' '{% endwith %}{{ key }}'}) def test_with02(self): - output = render('with02', {'dict': {'key': 50}}) - if settings.TEMPLATE_STRING_IF_INVALID: + output = self.engine.render_to_string('with02', {'dict': {'key': 50}}) + if self.engine.string_if_invalid: self.assertEqual(output, 'INVALID50-50-50INVALID') else: self.assertEqual(output, '50-50-50') @@ -31,23 +30,23 @@ class WithTagTests(SimpleTestCase): '{{ key }}-{{ dict.key }}-{{ key }}' '{% endwith %}{{ key }}'}) def test_legacywith02(self): - output = render('legacywith02', {'dict': {'key': 50}}) - if settings.TEMPLATE_STRING_IF_INVALID: + output = self.engine.render_to_string('legacywith02', {'dict': {'key': 50}}) + if self.engine.string_if_invalid: self.assertEqual(output, 'INVALID50-50-50INVALID') else: self.assertEqual(output, '50-50-50') @setup({'with03': '{% with a=alpha b=beta %}{{ a }}{{ b }}{% endwith %}'}) def test_with03(self): - output = render('with03', {'alpha': 'A', 'beta': 'B'}) + output = self.engine.render_to_string('with03', {'alpha': 'A', 'beta': 'B'}) self.assertEqual(output, 'AB') @setup({'with-error01': '{% with dict.key xx key %}{{ key }}{% endwith %}'}) def test_with_error01(self): with self.assertRaises(TemplateSyntaxError): - render('with-error01', {'dict': {'key': 50}}) + self.engine.render_to_string('with-error01', {'dict': {'key': 50}}) @setup({'with-error02': '{% with dict.key as %}{{ key }}{% endwith %}'}) def test_with_error02(self): with self.assertRaises(TemplateSyntaxError): - render('with-error02', {'dict': {'key': 50}}) + self.engine.render_to_string('with-error02', {'dict': {'key': 50}}) |
