Ticket #21451: 21451-patch-Django-1.6.diff

File 21451-patch-Django-1.6.diff, 2.4 KB (added by Aymeric Augustin, 11 years ago)
  • django/contrib/staticfiles/handlers.py

    diff --git a/django/contrib/staticfiles/handlers.py b/django/contrib/staticfiles/handlers.py
    index e6db3dc..ea46e05 100644
    a b class StaticFilesHandler(WSGIHandler):  
    6060                if settings.DEBUG:
    6161                    from django.views import debug
    6262                    return debug.technical_404_response(request, e)
     63                else:
     64                    raise
    6365        return super(StaticFilesHandler, self).get_response(request)
    6466
    6567    def __call__(self, environ, start_response):
  • django/test/testcases.py

    diff --git a/django/test/testcases.py b/django/test/testcases.py
    index 85ff66a..5055da3 100644
    a b class LiveServerThread(threading.Thread):  
    10811081                connections[alias] = conn
    10821082        try:
    10831083            # 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)
    10851088
    10861089            # Go through the list of possible ports, hoping that we can find
    10871090            # one that is free to use for the WSGI server.
  • tests/servers/tests.py

    diff --git a/tests/servers/tests.py b/tests/servers/tests.py
    index d4025c4..fac1d3b 100644
    a b from __future__ import unicode_literals  
    77import os
    88import socket
    99
     10from django.conf import settings
    1011from django.core.exceptions import ImproperlyConfigured
    1112from django.test import LiveServerTestCase
    1213from django.test.utils import override_settings
    class LiveServerDatabase(LiveServerBase):  
    178179            ['jane', 'robert', 'emily'],
    179180            lambda b: b.name
    180181        )
     182
     183@override_settings(DEBUG=True)
     184class 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')
Back to Top