summaryrefslogtreecommitdiff
path: root/tests/template_tests/syntax_tests/test_include.py
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-09-02 20:24:01 -0400
committerTim Graham <timograham@gmail.com>2017-09-22 12:51:18 -0400
commite62165b898785e890661953c3b2c9c36d98aee57 (patch)
treeda98862d4d7b03fd71f124f8ba6141e700ac51a0 /tests/template_tests/syntax_tests/test_include.py
parent96107e2844d27a7713152515051654ce70d57660 (diff)
Refs #27175 -- Removed exception silencing from the {% include %} template tag.
Per deprecation timeline.
Diffstat (limited to 'tests/template_tests/syntax_tests/test_include.py')
-rw-r--r--tests/template_tests/syntax_tests/test_include.py61
1 files changed, 11 insertions, 50 deletions
diff --git a/tests/template_tests/syntax_tests/test_include.py b/tests/template_tests/syntax_tests/test_include.py
index 760a801377..ca98e09771 100644
--- a/tests/template_tests/syntax_tests/test_include.py
+++ b/tests/template_tests/syntax_tests/test_include.py
@@ -1,10 +1,7 @@
-import warnings
-
from django.template import (
Context, Engine, TemplateDoesNotExist, TemplateSyntaxError, loader,
)
-from django.test import SimpleTestCase, ignore_warnings
-from django.utils.deprecation import RemovedInDjango21Warning
+from django.test import SimpleTestCase
from ..utils import setup
from .test_basic import basic_templates
@@ -39,24 +36,8 @@ class IncludeTagTests(SimpleTestCase):
@setup({'include04': 'a{% include "nonexistent" %}b'})
def test_include04(self):
template = self.engine.get_template('include04')
-
- if self.engine.debug:
- with self.assertRaises(TemplateDoesNotExist):
- template.render(Context({}))
- else:
- with warnings.catch_warnings(record=True) as warns:
- warnings.simplefilter('always')
- output = template.render(Context({}))
-
- self.assertEqual(output, "ab")
-
- self.assertEqual(len(warns), 1)
- self.assertEqual(
- str(warns[0].message),
- "Rendering {% include 'include04' %} raised "
- "TemplateDoesNotExist. In Django 2.1, this exception will be "
- "raised rather than silenced and rendered as an empty string.",
- )
+ with self.assertRaises(TemplateDoesNotExist):
+ template.render(Context({}))
@setup({
'include 05': 'template with a space',
@@ -178,48 +159,28 @@ class IncludeTagTests(SimpleTestCase):
@setup({'include-error07': '{% include "include-fail1" %}'}, include_fail_templates)
def test_include_error07(self):
template = self.engine.get_template('include-error07')
-
- if self.engine.debug:
- with self.assertRaises(RuntimeError):
- template.render(Context())
- else:
- with ignore_warnings(category=RemovedInDjango21Warning):
- self.assertEqual(template.render(Context()), '')
+ with self.assertRaises(RuntimeError):
+ template.render(Context())
@setup({'include-error08': '{% include "include-fail2" %}'}, include_fail_templates)
def test_include_error08(self):
template = self.engine.get_template('include-error08')
-
- if self.engine.debug:
- with self.assertRaises(TemplateSyntaxError):
- template.render(Context())
- else:
- with ignore_warnings(category=RemovedInDjango21Warning):
- self.assertEqual(template.render(Context()), '')
+ with self.assertRaises(TemplateSyntaxError):
+ template.render(Context())
@setup({'include-error09': '{% include failed_include %}'}, include_fail_templates)
def test_include_error09(self):
context = Context({'failed_include': 'include-fail1'})
template = self.engine.get_template('include-error09')
-
- if self.engine.debug:
- with self.assertRaises(RuntimeError):
- template.render(context)
- else:
- with ignore_warnings(category=RemovedInDjango21Warning):
- self.assertEqual(template.render(context), '')
+ with self.assertRaises(RuntimeError):
+ template.render(context)
@setup({'include-error10': '{% include failed_include %}'}, include_fail_templates)
def test_include_error10(self):
context = Context({'failed_include': 'include-fail2'})
template = self.engine.get_template('include-error10')
-
- if self.engine.debug:
- with self.assertRaises(TemplateSyntaxError):
- template.render(context)
- else:
- with ignore_warnings(category=RemovedInDjango21Warning):
- self.assertEqual(template.render(context), '')
+ with self.assertRaises(TemplateSyntaxError):
+ template.render(context)
class IncludeTests(SimpleTestCase):