summaryrefslogtreecommitdiff
path: root/tests/staticfiles_tests/test_management.py
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2018-04-25 10:35:54 +0200
committerClaude Paroz <claude@2xlibre.net>2018-04-25 10:38:13 +0200
commita9189d27efccdee0b5e8b84f69f9041176055769 (patch)
treeeebcbb05d8c18bcf93ed9d584945c35de49bc77c /tests/staticfiles_tests/test_management.py
parentc591bc3ccece1514d6b419826c7fa36ada9d9213 (diff)
downloaddjango-a9189d27efccdee0b5e8b84f69f9041176055769.tar.gz
Fixed #29353 -- Made StaticFilesHandler return a 404 response when settings.DEBUG is False
Diffstat (limited to 'tests/staticfiles_tests/test_management.py')
-rw-r--r--tests/staticfiles_tests/test_management.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/staticfiles_tests/test_management.py b/tests/staticfiles_tests/test_management.py
index 1472c7a488..74c7ef9fc6 100644
--- a/tests/staticfiles_tests/test_management.py
+++ b/tests/staticfiles_tests/test_management.py
@@ -16,7 +16,7 @@ from django.contrib.staticfiles.management.commands import (
)
from django.core.exceptions import ImproperlyConfigured
from django.core.management import CommandError, call_command
-from django.test import override_settings
+from django.test import RequestFactory, override_settings
from django.test.utils import extend_sys_path
from django.utils import timezone
from django.utils._os import symlinks_supported
@@ -44,6 +44,18 @@ class TestRunserver(StaticFilesTestCase):
command.get_handler(use_static_handler=True, insecure_serving=True)
self.assertEqual(mocked.call_count, 1)
+ def test_404_response(self):
+ command = runserver.Command()
+ handler = command.get_handler(use_static_handler=True, insecure_serving=True)
+ missing_static_file = os.path.join(settings.STATIC_URL, 'unknown.css')
+ req = RequestFactory().get(missing_static_file)
+ with override_settings(DEBUG=False):
+ response = handler.get_response(req)
+ self.assertEqual(response.status_code, 404)
+ with override_settings(DEBUG=True):
+ response = handler.get_response(req)
+ self.assertEqual(response.status_code, 404)
+
class TestFindStatic(TestDefaults, CollectionTestCase):
"""