summaryrefslogtreecommitdiff
path: root/tests/staticfiles_tests
diff options
context:
space:
mode:
authorJacob Walls <jacobtylerwalls@gmail.com>2021-02-26 07:23:26 -0500
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-03-03 11:27:08 +0100
commitb23232b6ab1b32969b018380922a6c550ba4f4aa (patch)
treee51e83cf4ace8680e7f73d8bc11ce9a65de15aff /tests/staticfiles_tests
parent7186c536c44c97ebfacc4672610184e2ce793cea (diff)
downloaddjango-b23232b6ab1b32969b018380922a6c550ba4f4aa.tar.gz
Fixed #27854 -- Added system check for nonexistent directories in STATICFILES_DIRS setting.
Diffstat (limited to 'tests/staticfiles_tests')
-rw-r--r--tests/staticfiles_tests/test_checks.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/tests/staticfiles_tests/test_checks.py b/tests/staticfiles_tests/test_checks.py
index 44666d141d..4b2195b46f 100644
--- a/tests/staticfiles_tests/test_checks.py
+++ b/tests/staticfiles_tests/test_checks.py
@@ -3,8 +3,8 @@ from unittest import mock
from django.conf import settings
from django.contrib.staticfiles.checks import check_finders
-from django.contrib.staticfiles.finders import BaseFinder
-from django.core.checks import Error
+from django.contrib.staticfiles.finders import BaseFinder, get_finder
+from django.core.checks import Error, Warning
from django.test import override_settings
from .cases import CollectionTestCase
@@ -91,3 +91,24 @@ class FindersCheckTests(CollectionTestCase):
id='staticfiles.E003',
),
])
+
+ def test_nonexistent_directories(self):
+ with self.settings(STATICFILES_DIRS=[
+ '/fake/path',
+ ('prefix', '/fake/prefixed/path'),
+ ]):
+ self.assertEqual(check_finders(None), [
+ Warning(
+ "The directory '/fake/path' in the STATICFILES_DIRS "
+ "setting does not exist.",
+ id='staticfiles.W004',
+ ),
+ Warning(
+ "The directory '/fake/prefixed/path' in the "
+ "STATICFILES_DIRS setting does not exist.",
+ id='staticfiles.W004',
+ ),
+ ])
+ # Nonexistent directories are skipped.
+ finder = get_finder('django.contrib.staticfiles.finders.FileSystemFinder')
+ self.assertEqual(list(finder.list(None)), [])