summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/view_tests/tests/test_static.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/view_tests/tests/test_static.py b/tests/view_tests/tests/test_static.py
index e2d22eb54c..01b4c2de7d 100644
--- a/tests/view_tests/tests/test_static.py
+++ b/tests/view_tests/tests/test_static.py
@@ -3,6 +3,7 @@ import unittest
from os import path
from django.conf.urls.static import static
+from django.core.exceptions import ImproperlyConfigured
from django.http import FileResponse, HttpResponseNotModified
from django.test import SimpleTestCase, override_settings
from django.utils.http import http_date
@@ -124,6 +125,22 @@ class StaticHelperTest(StaticTests):
super().tearDown()
urls.urlpatterns = self._old_views_urlpatterns
+ def test_prefix(self):
+ self.assertEqual(static('test')[0].regex.pattern, '^test(?P<path>.*)$')
+
+ @override_settings(DEBUG=False)
+ def test_debug_off(self):
+ """No URLs are served if DEBUG=False."""
+ self.assertEqual(static('test'), [])
+
+ def test_empty_prefix(self):
+ with self.assertRaisesMessage(ImproperlyConfigured, 'Empty static prefix not permitted'):
+ static('')
+
+ def test_special_prefix(self):
+ """No URLs are served if prefix contains '://'."""
+ self.assertEqual(static('http://'), [])
+
class StaticUtilsTests(unittest.TestCase):
def test_was_modified_since_fp(self):