Fixed #32665 -- Fixed caches system check crash when STATICFILES_DIRS is a list of 2-tuples.

Thanks Jared Lockhart for the report.

Regression in c36075ac1d.
This commit is contained in:
Mariusz Felisiak 2021-04-21 09:41:37 +02:00 committed by GitHub
parent 5c73fbb6a9
commit 34d1905712
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 4 deletions

View file

@ -91,6 +91,35 @@ class CheckCacheLocationTest(SimpleTestCase):
with self.subTest(setting=setting), self.settings(**settings):
self.assertEqual(check_cache_location_not_exposed(None), [])
def test_staticfiles_dirs_prefix(self):
root = pathlib.Path.cwd()
tests = [
(root, root, 'matches'),
(root / 'cache', root, 'is inside'),
(root, root / 'other', 'contains'),
]
for cache_path, setting_path, msg in tests:
settings = self.get_settings(
'STATICFILES_DIRS',
cache_path,
('prefix', setting_path),
)
with self.subTest(path=setting_path), self.settings(**settings):
msg = self.warning_message % (msg, 'STATICFILES_DIRS')
self.assertEqual(check_cache_location_not_exposed(None), [
Warning(msg, id='caches.W002'),
])
def test_staticfiles_dirs_prefix_not_conflict(self):
root = pathlib.Path.cwd()
settings = self.get_settings(
'STATICFILES_DIRS',
root / 'cache',
('prefix', root / 'other'),
)
with self.settings(**settings):
self.assertEqual(check_cache_location_not_exposed(None), [])
class CheckCacheAbsolutePath(SimpleTestCase):
def test_absolute_path(self):