mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Tested template info in debug view's text traceback
This commit is contained in:
parent
33421ed10c
commit
2eb1f15f62
2
tests/view_tests/templates/debug/template_error.html
Normal file
2
tests/view_tests/templates/debug/template_error.html
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Template with error:
|
||||||
|
{% cycle %}
|
@ -5,11 +5,13 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from django.conf.urls import url
|
from django.conf.urls import url
|
||||||
from django.core import mail
|
from django.core import mail
|
||||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||||
from django.db import DatabaseError, connection
|
from django.db import DatabaseError, connection
|
||||||
|
from django.shortcuts import render
|
||||||
from django.template import TemplateDoesNotExist
|
from django.template import TemplateDoesNotExist
|
||||||
from django.test import RequestFactory, SimpleTestCase, override_settings
|
from django.test import RequestFactory, SimpleTestCase, override_settings
|
||||||
from django.test.utils import LoggingCaptureMixin, patch_logger
|
from django.test.utils import LoggingCaptureMixin, patch_logger
|
||||||
@ -605,6 +607,26 @@ class PlainTextReportTests(SimpleTestCase):
|
|||||||
reporter = ExceptionReporter(request, None, "I'm a little teapot", None)
|
reporter = ExceptionReporter(request, None, "I'm a little teapot", None)
|
||||||
reporter.get_traceback_text()
|
reporter.get_traceback_text()
|
||||||
|
|
||||||
|
@override_settings(DEBUG=True)
|
||||||
|
def test_template_exception(self):
|
||||||
|
request = self.rf.get('/test_view/')
|
||||||
|
try:
|
||||||
|
render(request, 'debug/template_error.html')
|
||||||
|
except Exception:
|
||||||
|
exc_type, exc_value, tb = sys.exc_info()
|
||||||
|
reporter = ExceptionReporter(request, exc_type, exc_value, tb)
|
||||||
|
text = reporter.get_traceback_text()
|
||||||
|
templ_path = Path(Path(__file__).parent.parent, 'templates', 'debug', 'template_error.html')
|
||||||
|
self.assertIn(
|
||||||
|
'Template error:\n'
|
||||||
|
'In template %(path)s, error at line 2\n'
|
||||||
|
' \'cycle\' tag requires at least two arguments\n'
|
||||||
|
' 1 : Template with error:\n'
|
||||||
|
' 2 : {%% cycle %%} \n'
|
||||||
|
' 3 : ' % {'path': templ_path},
|
||||||
|
text
|
||||||
|
)
|
||||||
|
|
||||||
def test_request_with_items_key(self):
|
def test_request_with_items_key(self):
|
||||||
"""
|
"""
|
||||||
An exception report can be generated for requests with 'items' in
|
An exception report can be generated for requests with 'items' in
|
||||||
|
Loading…
Reference in New Issue
Block a user