diff --git a/django/views/debug.py b/django/views/debug.py index 2936b276df..4d68cd4d26 100644 --- a/django/views/debug.py +++ b/django/views/debug.py @@ -2,6 +2,7 @@ import functools import re import sys import types +from pathlib import Path from django.conf import settings from django.http import HttpResponse, HttpResponseNotFound @@ -15,13 +16,17 @@ from django.utils.module_loading import import_string from django.utils.translation import gettext as _ # Minimal Django templates engine to render the error templates -# regardless of the project's TEMPLATES setting. +# regardless of the project's TEMPLATES setting. Templates are +# read directly from the filesystem so that the error handler +# works even if the template loader is broken. DEBUG_ENGINE = Engine(debug=True) HIDDEN_SETTINGS = re.compile('API|TOKEN|KEY|SECRET|PASS|SIGNATURE', flags=re.IGNORECASE) CLEANSED_SUBSTITUTE = '********************' +CURRENT_DIR = Path(__file__).parent + class CallableSettingWrapper: """ @@ -320,13 +325,15 @@ class ExceptionReporter: def get_traceback_html(self): """Return HTML version of debug 500 HTTP error page.""" - t = DEBUG_ENGINE.from_string(TECHNICAL_500_TEMPLATE) + with Path(CURRENT_DIR, 'templates', 'technical_500.html').open() as fh: + t = DEBUG_ENGINE.from_string(fh.read()) c = Context(self.get_traceback_data(), use_l10n=False) return t.render(c) def get_traceback_text(self): """Return plain text version of debug 500 HTTP error page.""" - t = DEBUG_ENGINE.from_string(TECHNICAL_500_TEXT_TEMPLATE) + with Path(CURRENT_DIR, 'templates', 'technical_500.txt').open() as fh: + t = DEBUG_ENGINE.from_string(fh.read()) c = Context(self.get_traceback_data(), autoescape=False, use_l10n=False) return t.render(c) @@ -480,7 +487,8 @@ def technical_404_response(request, exception): module = obj.__module__ caller = '%s.%s' % (module, caller) - t = DEBUG_ENGINE.from_string(TECHNICAL_404_TEMPLATE) + with Path(CURRENT_DIR, 'templates', 'technical_404.html').open() as fh: + t = DEBUG_ENGINE.from_string(fh.read()) c = Context({ 'urlconf': urlconf, 'root_urlconf': settings.ROOT_URLCONF, @@ -496,7 +504,8 @@ def technical_404_response(request, exception): def default_urlconf(request): """Create an empty URLconf 404 error response.""" - t = DEBUG_ENGINE.from_string(DEFAULT_URLCONF_TEMPLATE) + with Path(CURRENT_DIR, 'templates', 'default_urlconf.html').open() as fh: + t = DEBUG_ENGINE.from_string(fh.read()) c = Context({ "title": _("Welcome to Django"), "heading": _("It worked!"), @@ -511,744 +520,3 @@ def default_urlconf(request): }) return HttpResponse(t.render(c), content_type='text/html') - - -# -# Templates are embedded in the file so that we know the error handler will -# always work even if the template loader is broken. -# - -TECHNICAL_500_TEMPLATE = (""" - - - - - - {% if exception_type %}{{ exception_type }}{% else %}Report{% endif %}""" -r"""{% if request %} at {{ request.path_info|escape }}{% endif %} - - {% if not is_email %} - - {% endif %} - - -
-

{% if exception_type %}{{ exception_type }}{% else %}Report{% endif %}""" - """{% if request %} at {{ request.path_info|escape }}{% endif %}

-
"""
- """{% if exception_value %}{{ exception_value|force_escape }}{% else %}No exception message supplied{% endif %}"""
-"""
- -{% if request %} - - - - - - - - -{% endif %} - - - - -{% if exception_type %} - - - - -{% endif %} -{% if exception_type and exception_value %} - - - - -{% endif %} -{% if lastframe %} - - - - -{% endif %} - - - - - - - - - - - - - - - - -
Request Method:{{ request.META.REQUEST_METHOD }}
Request URL:{{ request.get_raw_uri|escape }}
Django Version:{{ django_version_info }}
Exception Type:{{ exception_type }}
Exception Value:
{{ exception_value|force_escape }}
Exception Location:{{ lastframe.filename|escape }} in {{ lastframe.function|escape }}, line {{ lastframe.lineno }}
Python Executable:{{ sys_executable|escape }}
Python Version:{{ sys_version_info }}
Python Path:
{{ sys_path|pprint }}
Server time:{{server_time|date:"r"}}
-
-{% if unicode_hint %} -
-

Unicode error hint

-

The string that could not be encoded/decoded was: {{ unicode_hint|force_escape }}

-
-{% endif %} -{% if template_does_not_exist %} -
-

Template-loader postmortem

- {% if postmortem %} -

Django tried loading these templates, in this order:

- {% for entry in postmortem %} -

Using engine {{ entry.backend.name }}:

- - {% endfor %} - {% else %} -

No templates were found because your 'TEMPLATES' setting is not configured.

- {% endif %} -
-{% endif %} -{% if template_info %} -
-

Error during template rendering

-

In template {{ template_info.name }}, error at line {{ template_info.line }}

-

{{ template_info.message }}

- - {% for source_line in template_info.source_lines %} - {% if source_line.0 == template_info.line %} - - - - {% else %} - - - {% endif %} - {% endfor %} -
{{ source_line.0 }}{{ template_info.before }}""" - """{{ template_info.during }}""" - """{{ template_info.after }}
{{ source_line.0 }}{{ source_line.1 }}
-
-{% endif %} -{% if frames %} -
-

Traceback {% if not is_email %} - Switch to copy-and-paste view{% endif %} -

- {% autoescape off %} -
- -
- {% endautoescape %} -
-{% if not is_email %} -
- - - - - -

- -
-
-
-{% endif %} -{% endif %} - -
-

Request information

- -{% if request %} - {% if user_str %} -

USER

-

{{ user_str }}

- {% endif %} - -

GET

- {% if request.GET %} - - - - - - - - - {% for k, v in request_GET_items %} - - - - - {% endfor %} - -
VariableValue
{{ k }}
{{ v|pprint }}
- {% else %} -

No GET data

- {% endif %} - -

POST

- {% if filtered_POST_items %} - - - - - - - - - {% for k, v in filtered_POST_items %} - - - - - {% endfor %} - -
VariableValue
{{ k }}
{{ v|pprint }}
- {% else %} -

No POST data

- {% endif %} -

FILES

- {% if request.FILES %} - - - - - - - - - {% for k, v in request_FILES_items %} - - - - - {% endfor %} - -
VariableValue
{{ k }}
{{ v|pprint }}
- {% else %} -

No FILES data

- {% endif %} - - - - {% if request.COOKIES %} - - - - - - - - - {% for k, v in request_COOKIES_items %} - - - - - {% endfor %} - -
VariableValue
{{ k }}
{{ v|pprint }}
- {% else %} -

No cookie data

- {% endif %} - -

META

- - - - - - - - - {% for var in request.META.items|dictsort:0 %} - - - - - {% endfor %} - -
VariableValue
{{ var.0 }}
{{ var.1|pprint }}
-{% else %} -

Request data not supplied

-{% endif %} - -

Settings

-

Using settings module {{ settings.SETTINGS_MODULE }}

- - - - - - - - - {% for var in settings.items|dictsort:0 %} - - - - - {% endfor %} - -
SettingValue
{{ var.0 }}
{{ var.1|pprint }}
- -
-{% if not is_email %} -
-

- You're seeing this error because you have DEBUG = True in your - Django settings file. Change that to False, and Django will - display a standard page generated by the handler for this status code. -

-
-{% endif %} - - -""") # NOQA - -TECHNICAL_500_TEXT_TEMPLATE = ("""""" -"""{% firstof exception_type 'Report' %}{% if request %} at {{ request.path_info }}{% endif %} -{% firstof exception_value 'No exception message supplied' %} -{% if request %} -Request Method: {{ request.META.REQUEST_METHOD }} -Request URL: {{ request.get_raw_uri }}{% endif %} -Django Version: {{ django_version_info }} -Python Executable: {{ sys_executable }} -Python Version: {{ sys_version_info }} -Python Path: {{ sys_path }} -Server time: {{server_time|date:"r"}} -Installed Applications: -{{ settings.INSTALLED_APPS|pprint }} -Installed Middleware: -{{ settings.MIDDLEWARE|pprint }}""" -""" -{% if template_does_not_exist %}Template loader postmortem -{% if postmortem %}Django tried loading these templates, in this order: -{% for entry in postmortem %} -Using engine {{ entry.backend.name }}: -{% if entry.tried %}{% for attempt in entry.tried %}""" -""" * {{ attempt.0.loader_name }}: {{ attempt.0.name }} ({{ attempt.1 }}) -{% endfor %}{% else %} This engine did not provide a list of tried templates. -{% endif %}{% endfor %} -{% else %}No templates were found because your 'TEMPLATES' setting is not configured. -{% endif %} -{% endif %}{% if template_info %} -Template error: -In template {{ template_info.name }}, error at line {{ template_info.line }} - {{ template_info.message }} -{% for source_line in template_info.source_lines %}""" -"{% if source_line.0 == template_info.line %}" -" {{ source_line.0 }} : {{ template_info.before }} {{ template_info.during }} {{ template_info.after }}" -"{% else %}" -" {{ source_line.0 }} : {{ source_line.1 }}" -"""{% endif %}{% endfor %}{% endif %}{% if frames %} - -Traceback:""" -"{% for frame in frames %}" -"{% ifchanged frame.exc_cause %}" -" {% if frame.exc_cause %}" """ - {% if frame.exc_cause_explicit %} - The above exception ({{ frame.exc_cause }}) was the direct cause of the following exception: - {% else %} - During handling of the above exception ({{ frame.exc_cause }}), another exception occurred: - {% endif %} - {% endif %} -{% endifchanged %} -File "{{ frame.filename }}" in {{ frame.function }} -{% if frame.context_line %} {{ frame.lineno }}. {{ frame.context_line }}{% endif %} -{% endfor %} -{% if exception_type %}Exception Type: {{ exception_type }}{% if request %} at {{ request.path_info }}{% endif %} -{% if exception_value %}Exception Value: {{ exception_value }}{% endif %}{% endif %}{% endif %} -{% if request %}Request information: -{% if user_str %}USER: {{ user_str }}{% endif %} - -GET:{% for k, v in request_GET_items %} -{{ k }} = {{ v|stringformat:"r" }}{% empty %} No GET data{% endfor %} - -POST:{% for k, v in filtered_POST_items %} -{{ k }} = {{ v|stringformat:"r" }}{% empty %} No POST data{% endfor %} - -FILES:{% for k, v in request_FILES_items %} -{{ k }} = {{ v|stringformat:"r" }}{% empty %} No FILES data{% endfor %} - -COOKIES:{% for k, v in request_COOKIES_items %} -{{ k }} = {{ v|stringformat:"r" }}{% empty %} No cookie data{% endfor %} - -META:{% for k, v in request.META.items|dictsort:0 %} -{{ k }} = {{ v|stringformat:"r" }}{% endfor %} -{% else %}Request data not supplied -{% endif %} -Settings: -Using settings module {{ settings.SETTINGS_MODULE }}{% for k, v in settings.items|dictsort:0 %} -{{ k }} = {{ v|stringformat:"r" }}{% endfor %} - -{% if not is_email %} -You're seeing this error because you have DEBUG = True in your -Django settings file. Change that to False, and Django will -display a standard page generated by the handler for this status code. -{% endif %} -""") # NOQA - -TECHNICAL_404_TEMPLATE = """ - - - - - Page not found at {{ request.path_info|escape }} - - - - -
-

Page not found (404)

- - - - - - - - - - {% if raising_view_name %} - - - - - {% endif %} -
Request Method:{{ request.META.REQUEST_METHOD }}
Request URL:{{ request.build_absolute_uri|escape }}
Raised by:{{ raising_view_name }}
-
-
- {% if urlpatterns %} -

- Using the URLconf defined in {{ urlconf }}, - Django tried these URL patterns, in this order: -

-
    - {% for pattern in urlpatterns %} -
  1. - {% for pat in pattern %} - {{ pat.regex.pattern }} - {% if forloop.last and pat.name %}[name='{{ pat.name }}']{% endif %} - {% endfor %} -
  2. - {% endfor %} -
-

- {% if request_path %} - The current path, {{ request_path|escape }},{% else %} - The empty path{% endif %} didn't match any of these. -

- {% else %} -

{{ reason }}

- {% endif %} -
- -
-

- You're seeing this error because you have DEBUG = True in - your Django settings file. Change that to False, and Django - will display a standard 404 page. -

-
- - -""" - -DEFAULT_URLCONF_TEMPLATE = """ - - - - {{ title }} - - - - -
-

{{ heading }}

-

{{ subheading }}

-
- -
-

- {{ instructions|safe }} -

-
- -
-

- {{ explanation|safe }} -

-
- -""" diff --git a/django/views/templates/default_urlconf.html b/django/views/templates/default_urlconf.html new file mode 100644 index 0000000000..f080a4ea29 --- /dev/null +++ b/django/views/templates/default_urlconf.html @@ -0,0 +1,44 @@ + + + + {{ title }} + + + + +
+

{{ heading }}

+

{{ subheading }}

+
+ +
+

{{ instructions|safe }}

+
+ +
+

{{ explanation|safe }}

+
+ diff --git a/django/views/templates/technical_404.html b/django/views/templates/technical_404.html new file mode 100644 index 0000000000..b88fecf2eb --- /dev/null +++ b/django/views/templates/technical_404.html @@ -0,0 +1,79 @@ + + + + + Page not found at {{ request.path_info|escape }} + + + + +
+

Page not found (404)

+ + + + + + + + + + {% if raising_view_name %} + + + + + {% endif %} +
Request Method:{{ request.META.REQUEST_METHOD }}
Request URL:{{ request.build_absolute_uri|escape }}
Raised by:{{ raising_view_name }}
+
+
+ {% if urlpatterns %} +

+ Using the URLconf defined in {{ urlconf }}, + Django tried these URL patterns, in this order: +

+
    + {% for pattern in urlpatterns %} +
  1. + {% for pat in pattern %} + {{ pat.regex.pattern }} + {% if forloop.last and pat.name %}[name='{{ pat.name }}']{% endif %} + {% endfor %} +
  2. + {% endfor %} +
+

+ {% if request_path %} + The current path, {{ request_path|escape }},{% else %} + The empty path{% endif %} didn't match any of these. +

+ {% else %} +

{{ reason }}

+ {% endif %} +
+ +
+

+ You're seeing this error because you have DEBUG = True in + your Django settings file. Change that to False, and Django + will display a standard 404 page. +

+
+ + diff --git a/django/views/templates/technical_500.html b/django/views/templates/technical_500.html new file mode 100644 index 0000000000..945c27827a --- /dev/null +++ b/django/views/templates/technical_500.html @@ -0,0 +1,503 @@ + + + + + + {% if exception_type %}{{ exception_type }}{% else %}Report{% endif %} + {% if request %} at {{ request.path_info|escape }}{% endif %} + + {% if not is_email %} + + {% endif %} + + +
+

{% if exception_type %}{{ exception_type }}{% else %}Report{% endif %} + {% if request %} at {{ request.path_info|escape }}{% endif %}

+
{% if exception_value %}{{ exception_value|force_escape }}{% else %}No exception message supplied{% endif %}
+ +{% if request %} + + + + + + + + +{% endif %} + + + + +{% if exception_type %} + + + + +{% endif %} +{% if exception_type and exception_value %} + + + + +{% endif %} +{% if lastframe %} + + + + +{% endif %} + + + + + + + + + + + + + + + + +
Request Method:{{ request.META.REQUEST_METHOD }}
Request URL:{{ request.get_raw_uri|escape }}
Django Version:{{ django_version_info }}
Exception Type:{{ exception_type }}
Exception Value:
{{ exception_value|force_escape }}
Exception Location:{{ lastframe.filename|escape }} in {{ lastframe.function|escape }}, line {{ lastframe.lineno }}
Python Executable:{{ sys_executable|escape }}
Python Version:{{ sys_version_info }}
Python Path:
{{ sys_path|pprint }}
Server time:{{server_time|date:"r"}}
+
+{% if unicode_hint %} +
+

Unicode error hint

+

The string that could not be encoded/decoded was: {{ unicode_hint|force_escape }}

+
+{% endif %} +{% if template_does_not_exist %} +
+

Template-loader postmortem

+ {% if postmortem %} +

Django tried loading these templates, in this order:

+ {% for entry in postmortem %} +

Using engine {{ entry.backend.name }}:

+ + {% endfor %} + {% else %} +

No templates were found because your 'TEMPLATES' setting is not configured.

+ {% endif %} +
+{% endif %} +{% if template_info %} +
+

Error during template rendering

+

In template {{ template_info.name }}, error at line {{ template_info.line }}

+

{{ template_info.message }}

+ + {% for source_line in template_info.source_lines %} + {% if source_line.0 == template_info.line %} + + + + {% else %} + + + {% endif %} + {% endfor %} +
{{ source_line.0 }}{{ template_info.before }}{{ template_info.during }}{{ template_info.after }}
{{ source_line.0 }}{{ source_line.1 }}
+
+{% endif %} +{% if frames %} +
+

Traceback {% if not is_email %} + Switch to copy-and-paste view{% endif %} +

+ {% autoescape off %} +
+ +
+ {% endautoescape %} +
+{% if not is_email %} +
+ + + + + +

+ +
+
+
+{% endif %} +{% endif %} + +
+

Request information

+ +{% if request %} + {% if user_str %} +

USER

+

{{ user_str }}

+ {% endif %} + +

GET

+ {% if request.GET %} + + + + + + + + + {% for k, v in request_GET_items %} + + + + + {% endfor %} + +
VariableValue
{{ k }}
{{ v|pprint }}
+ {% else %} +

No GET data

+ {% endif %} + +

POST

+ {% if filtered_POST_items %} + + + + + + + + + {% for k, v in filtered_POST_items %} + + + + + {% endfor %} + +
VariableValue
{{ k }}
{{ v|pprint }}
+ {% else %} +

No POST data

+ {% endif %} +

FILES

+ {% if request.FILES %} + + + + + + + + + {% for k, v in request_FILES_items %} + + + + + {% endfor %} + +
VariableValue
{{ k }}
{{ v|pprint }}
+ {% else %} +

No FILES data

+ {% endif %} + + + + {% if request.COOKIES %} + + + + + + + + + {% for k, v in request_COOKIES_items %} + + + + + {% endfor %} + +
VariableValue
{{ k }}
{{ v|pprint }}
+ {% else %} +

No cookie data

+ {% endif %} + +

META

+ + + + + + + + + {% for var in request.META.items|dictsort:0 %} + + + + + {% endfor %} + +
VariableValue
{{ var.0 }}
{{ var.1|pprint }}
+{% else %} +

Request data not supplied

+{% endif %} + +

Settings

+

Using settings module {{ settings.SETTINGS_MODULE }}

+ + + + + + + + + {% for var in settings.items|dictsort:0 %} + + + + + {% endfor %} + +
SettingValue
{{ var.0 }}
{{ var.1|pprint }}
+ +
+{% if not is_email %} +
+

+ You're seeing this error because you have DEBUG = True in your + Django settings file. Change that to False, and Django will + display a standard page generated by the handler for this status code. +

+
+{% endif %} + + diff --git a/django/views/templates/technical_500.txt b/django/views/templates/technical_500.txt new file mode 100644 index 0000000000..1777051906 --- /dev/null +++ b/django/views/templates/technical_500.txt @@ -0,0 +1,66 @@ +{% firstof exception_type 'Report' %}{% if request %} at {{ request.path_info }}{% endif %} +{% firstof exception_value 'No exception message supplied' %} +{% if request %} +Request Method: {{ request.META.REQUEST_METHOD }} +Request URL: {{ request.get_raw_uri }}{% endif %} +Django Version: {{ django_version_info }} +Python Executable: {{ sys_executable }} +Python Version: {{ sys_version_info }} +Python Path: {{ sys_path }} +Server time: {{server_time|date:"r"}} +Installed Applications: +{{ settings.INSTALLED_APPS|pprint }} +Installed Middleware: +{{ settings.MIDDLEWARE|pprint }} +{% if template_does_not_exist %}Template loader postmortem +{% if postmortem %}Django tried loading these templates, in this order: +{% for entry in postmortem %} +Using engine {{ entry.backend.name }}: +{% if entry.tried %}{% for attempt in entry.tried %} * {{ attempt.0.loader_name }}: {{ attempt.0.name }} ({{ attempt.1 }}) +{% endfor %}{% else %} This engine did not provide a list of tried templates. +{% endif %}{% endfor %} +{% else %}No templates were found because your 'TEMPLATES' setting is not configured. +{% endif %} +{% endif %}{% if template_info %} +Template error: +In template {{ template_info.name }}, error at line {{ template_info.line }} + {{ template_info.message }} +{% for source_line in template_info.source_lines %}{% if source_line.0 == template_info.line %} {{ source_line.0 }} : {{ template_info.before }} {{ template_info.during }} {{ template_info.after }}{% else %} {{ source_line.0 }} : {{ source_line.1 }}{% endif %}{% endfor %}{% endif %}{% if frames %} + +Traceback: +{% for frame in frames %}{% ifchanged frame.exc_cause %}{% if frame.exc_cause %} +{% if frame.exc_cause_explicit %}The above exception ({{ frame.exc_cause }}) was the direct cause of the following exception:{% else %}During handling of the above exception ({{ frame.exc_cause }}), another exception occurred:{% endif %} +{% endif %}{% endifchanged %} +File "{{ frame.filename }}" in {{ frame.function }} +{% if frame.context_line %} {{ frame.lineno }}. {{ frame.context_line }}{% endif %} +{% endfor %} +{% if exception_type %}Exception Type: {{ exception_type }}{% if request %} at {{ request.path_info }}{% endif %} +{% if exception_value %}Exception Value: {{ exception_value }}{% endif %}{% endif %}{% endif %} +{% if request %}Request information: +{% if user_str %}USER: {{ user_str }}{% endif %} + +GET:{% for k, v in request_GET_items %} +{{ k }} = {{ v|stringformat:"r" }}{% empty %} No GET data{% endfor %} + +POST:{% for k, v in filtered_POST_items %} +{{ k }} = {{ v|stringformat:"r" }}{% empty %} No POST data{% endfor %} + +FILES:{% for k, v in request_FILES_items %} +{{ k }} = {{ v|stringformat:"r" }}{% empty %} No FILES data{% endfor %} + +COOKIES:{% for k, v in request_COOKIES_items %} +{{ k }} = {{ v|stringformat:"r" }}{% empty %} No cookie data{% endfor %} + +META:{% for k, v in request.META.items|dictsort:0 %} +{{ k }} = {{ v|stringformat:"r" }}{% endfor %} +{% else %}Request data not supplied +{% endif %} +Settings: +Using settings module {{ settings.SETTINGS_MODULE }}{% for k, v in settings.items|dictsort:0 %} +{{ k }} = {{ v|stringformat:"r" }}{% endfor %} + +{% if not is_email %} +You're seeing this error because you have DEBUG = True in your +Django settings file. Change that to False, and Django will +display a standard page generated by the handler for this status code. +{% endif %} diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py index 828d59a88f..b026618b4d 100644 --- a/tests/view_tests/tests/test_debug.py +++ b/tests/view_tests/tests/test_debug.py @@ -279,7 +279,7 @@ class ExceptionReporterTests(SimpleTestCase): exc_type, exc_value, tb = sys.exc_info() reporter = ExceptionReporter(request, exc_type, exc_value, tb) html = reporter.get_traceback_html() - self.assertIn('

ValueError at /test_view/

', html) + self.assertInHTML('

ValueError at /test_view/

', html) self.assertIn('
Can't find my keys
', html) self.assertIn('Request Method:', html) self.assertIn('Request URL:', html) @@ -299,7 +299,7 @@ class ExceptionReporterTests(SimpleTestCase): exc_type, exc_value, tb = sys.exc_info() reporter = ExceptionReporter(None, exc_type, exc_value, tb) html = reporter.get_traceback_html() - self.assertIn('

ValueError

', html) + self.assertInHTML('

ValueError

', html) self.assertIn('
Can't find my keys
', html) self.assertNotIn('Request Method:', html) self.assertNotIn('Request URL:', html) @@ -333,7 +333,7 @@ class ExceptionReporterTests(SimpleTestCase): request = self.rf.get('/test_view/') reporter = ExceptionReporter(request, None, None, None) html = reporter.get_traceback_html() - self.assertIn('

Report at /test_view/

', html) + self.assertInHTML('

Report at /test_view/

', html) self.assertIn('
No exception message supplied
', html) self.assertIn('Request Method:', html) self.assertIn('Request URL:', html) @@ -376,7 +376,7 @@ class ExceptionReporterTests(SimpleTestCase): request = self.rf.get('/test_view/') reporter = ExceptionReporter(request, None, "I'm a little teapot", None) html = reporter.get_traceback_html() - self.assertIn('

Report at /test_view/

', html) + self.assertInHTML('

Report at /test_view/

', html) self.assertIn('
I'm a little teapot
', html) self.assertIn('Request Method:', html) self.assertIn('Request URL:', html) @@ -389,7 +389,7 @@ class ExceptionReporterTests(SimpleTestCase): def test_message_only(self): reporter = ExceptionReporter(None, None, "I'm a little teapot", None) html = reporter.get_traceback_html() - self.assertIn('

Report

', html) + self.assertInHTML('

Report

', html) self.assertIn('
I'm a little teapot
', html) self.assertNotIn('Request Method:', html) self.assertNotIn('Request URL:', html) @@ -457,7 +457,7 @@ class ExceptionReporterTests(SimpleTestCase): exc_type, exc_value, tb = sys.exc_info() reporter = ExceptionReporter(request, exc_type, exc_value, tb) html = reporter.get_traceback_html() - self.assertIn('

%sError at /test_view/

' % 'ModuleNotFound' if PY36 else 'Import', html) + self.assertInHTML('

%sError at /test_view/

' % ('ModuleNotFound' if PY36 else 'Import'), html) def test_ignore_traceback_evaluation_exceptions(self): """ @@ -544,7 +544,7 @@ class ExceptionReporterTests(SimpleTestCase): reporter = ExceptionReporter(request, exc_type, exc_value, tb) html = reporter.get_traceback_html() - self.assertIn('

ValueError at /test_view/

', html) + self.assertInHTML('

ValueError at /test_view/

', html) self.assertIn('
Oops
', html) self.assertIn('

USER

', html) self.assertIn('

[unable to retrieve the current user]

', html)