diff --git a/django/contrib/staticfiles/handlers.py b/django/contrib/staticfiles/handlers.py
index e6db3dc..ea46e05 100644
a
|
b
|
class StaticFilesHandler(WSGIHandler):
|
60 | 60 | if settings.DEBUG: |
61 | 61 | from django.views import debug |
62 | 62 | return debug.technical_404_response(request, e) |
| 63 | else: |
| 64 | raise |
63 | 65 | return super(StaticFilesHandler, self).get_response(request) |
64 | 66 | |
65 | 67 | def __call__(self, environ, start_response): |
diff --git a/django/test/testcases.py b/django/test/testcases.py
index 85ff66a..5055da3 100644
a
|
b
|
class LiveServerThread(threading.Thread):
|
1081 | 1081 | connections[alias] = conn |
1082 | 1082 | try: |
1083 | 1083 | # Create the handler for serving static and media files |
1084 | | handler = StaticFilesHandler(_MediaFilesHandler(WSGIHandler())) |
| 1084 | handler = WSGIHandler() |
| 1085 | if settings.MEDIA_URL: |
| 1086 | handler = _MediaFilesHandler(handler) |
| 1087 | handler = StaticFilesHandler(handler) |
1085 | 1088 | |
1086 | 1089 | # Go through the list of possible ports, hoping that we can find |
1087 | 1090 | # one that is free to use for the WSGI server. |
diff --git a/tests/servers/tests.py b/tests/servers/tests.py
index d4025c4..fac1d3b 100644
a
|
b
|
from __future__ import unicode_literals
|
7 | 7 | import os |
8 | 8 | import socket |
9 | 9 | |
| 10 | from django.conf import settings |
10 | 11 | from django.core.exceptions import ImproperlyConfigured |
11 | 12 | from django.test import LiveServerTestCase |
12 | 13 | from django.test.utils import override_settings |
… |
… |
class LiveServerDatabase(LiveServerBase):
|
178 | 179 | ['jane', 'robert', 'emily'], |
179 | 180 | lambda b: b.name |
180 | 181 | ) |
| 182 | |
| 183 | @override_settings(DEBUG=True) |
| 184 | class LiveServerWithoutMediaUrlInDebugMode(LiveServerBase): |
| 185 | |
| 186 | @classmethod |
| 187 | def setUpClass(cls): |
| 188 | MEDIA_URL = TEST_SETTINGS.pop('MEDIA_URL') |
| 189 | super(LiveServerWithoutMediaUrlInDebugMode, cls).setUpClass() |
| 190 | TEST_SETTINGS['MEDIA_URL'] = MEDIA_URL |
| 191 | |
| 192 | def test_existing_url(self): |
| 193 | """ |
| 194 | Ensure that LiveServerTestCase serves views when MEDIA_URL is unset |
| 195 | and DEBUG is True. Refs #21451. |
| 196 | """ |
| 197 | f = self.urlopen('/example_view/') |
| 198 | self.assertEqual(f.read(), b'example view') |