summaryrefslogtreecommitdiff
path: root/tests/staticfiles_tests/test_checks.py
diff options
context:
space:
mode:
authordjango-bot <ops@djangoproject.com>2022-02-03 20:24:19 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-07 20:37:05 +0100
commit9c19aff7c7561e3a82978a272ecdaad40dda5c00 (patch)
treef0506b668a013d0063e5fba3dbf4863b466713ba /tests/staticfiles_tests/test_checks.py
parentf68fa8b45dfac545cfc4111d4e52804c86db68d3 (diff)
Refs #33476 -- Reformatted code with Black.
Diffstat (limited to 'tests/staticfiles_tests/test_checks.py')
-rw-r--r--tests/staticfiles_tests/test_checks.py125
1 files changed, 71 insertions, 54 deletions
diff --git a/tests/staticfiles_tests/test_checks.py b/tests/staticfiles_tests/test_checks.py
index 4b2195b46f..5a4cbe7d0f 100644
--- a/tests/staticfiles_tests/test_checks.py
+++ b/tests/staticfiles_tests/test_checks.py
@@ -16,15 +16,15 @@ class FindersCheckTests(CollectionTestCase):
def test_base_finder_check_not_implemented(self):
finder = BaseFinder()
- msg = 'subclasses may provide a check() method to verify the finder is configured correctly.'
+ msg = "subclasses may provide a check() method to verify the finder is configured correctly."
with self.assertRaisesMessage(NotImplementedError, msg):
finder.check()
def test_check_finders(self):
"""check_finders() concatenates all errors."""
- error1 = Error('1')
- error2 = Error('2')
- error3 = Error('3')
+ error1 = Error("1")
+ error2 = Error("2")
+ error3 = Error("3")
def get_finders():
class Finder1(BaseFinder):
@@ -44,71 +44,88 @@ class FindersCheckTests(CollectionTestCase):
return [Finder1(), Finder2(), Finder3(), Finder4()]
- with mock.patch('django.contrib.staticfiles.checks.get_finders', get_finders):
+ with mock.patch("django.contrib.staticfiles.checks.get_finders", get_finders):
errors = check_finders(None)
self.assertEqual(errors, [error1, error2, error3])
def test_no_errors_with_test_settings(self):
self.assertEqual(check_finders(None), [])
- @override_settings(STATICFILES_DIRS='a string')
+ @override_settings(STATICFILES_DIRS="a string")
def test_dirs_not_tuple_or_list(self):
- self.assertEqual(check_finders(None), [
- Error(
- 'The STATICFILES_DIRS setting is not a tuple or list.',
- hint='Perhaps you forgot a trailing comma?',
- id='staticfiles.E001',
- )
- ])
+ self.assertEqual(
+ check_finders(None),
+ [
+ Error(
+ "The STATICFILES_DIRS setting is not a tuple or list.",
+ hint="Perhaps you forgot a trailing comma?",
+ id="staticfiles.E001",
+ )
+ ],
+ )
def test_dirs_contains_static_root(self):
with self.settings(STATICFILES_DIRS=[settings.STATIC_ROOT]):
- self.assertEqual(check_finders(None), [
- Error(
- 'The STATICFILES_DIRS setting should not contain the '
- 'STATIC_ROOT setting.',
- id='staticfiles.E002',
- )
- ])
+ self.assertEqual(
+ check_finders(None),
+ [
+ Error(
+ "The STATICFILES_DIRS setting should not contain the "
+ "STATIC_ROOT setting.",
+ id="staticfiles.E002",
+ )
+ ],
+ )
def test_dirs_contains_static_root_in_tuple(self):
- with self.settings(STATICFILES_DIRS=[('prefix', settings.STATIC_ROOT)]):
- self.assertEqual(check_finders(None), [
- Error(
- 'The STATICFILES_DIRS setting should not contain the '
- 'STATIC_ROOT setting.',
- id='staticfiles.E002',
- )
- ])
+ with self.settings(STATICFILES_DIRS=[("prefix", settings.STATIC_ROOT)]):
+ self.assertEqual(
+ check_finders(None),
+ [
+ Error(
+ "The STATICFILES_DIRS setting should not contain the "
+ "STATIC_ROOT setting.",
+ id="staticfiles.E002",
+ )
+ ],
+ )
def test_prefix_contains_trailing_slash(self):
- static_dir = Path(TEST_ROOT) / 'project' / 'documents'
- with self.settings(STATICFILES_DIRS=[('prefix/', static_dir)]):
- self.assertEqual(check_finders(None), [
- Error(
- "The prefix 'prefix/' in the STATICFILES_DIRS setting must "
- "not end with a slash.",
- id='staticfiles.E003',
- ),
- ])
+ static_dir = Path(TEST_ROOT) / "project" / "documents"
+ with self.settings(STATICFILES_DIRS=[("prefix/", static_dir)]):
+ self.assertEqual(
+ check_finders(None),
+ [
+ Error(
+ "The prefix 'prefix/' in the STATICFILES_DIRS setting must "
+ "not end with a slash.",
+ 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',
- ),
- ])
+ 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')
+ finder = get_finder("django.contrib.staticfiles.finders.FileSystemFinder")
self.assertEqual(list(finder.list(None)), [])