Used CollectionTestCase in FindersCheckTests tests.
This commit is contained in:
parent
be8faa7c75
commit
7186c536c4
|
@ -1,13 +1,18 @@
|
||||||
|
from pathlib import Path
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.staticfiles.checks import check_finders
|
from django.contrib.staticfiles.checks import check_finders
|
||||||
from django.contrib.staticfiles.finders import BaseFinder
|
from django.contrib.staticfiles.finders import BaseFinder
|
||||||
from django.core.checks import Error
|
from django.core.checks import Error
|
||||||
from django.test import SimpleTestCase, override_settings
|
from django.test import override_settings
|
||||||
|
|
||||||
|
from .cases import CollectionTestCase
|
||||||
|
from .settings import TEST_ROOT
|
||||||
|
|
||||||
|
|
||||||
class FindersCheckTests(SimpleTestCase):
|
class FindersCheckTests(CollectionTestCase):
|
||||||
|
run_collectstatic_in_setUp = False
|
||||||
|
|
||||||
def test_base_finder_check_not_implemented(self):
|
def test_base_finder_check_not_implemented(self):
|
||||||
finder = BaseFinder()
|
finder = BaseFinder()
|
||||||
|
@ -56,8 +61,8 @@ class FindersCheckTests(SimpleTestCase):
|
||||||
)
|
)
|
||||||
])
|
])
|
||||||
|
|
||||||
@override_settings(STATICFILES_DIRS=['/fake/path', settings.STATIC_ROOT])
|
|
||||||
def test_dirs_contains_static_root(self):
|
def test_dirs_contains_static_root(self):
|
||||||
|
with self.settings(STATICFILES_DIRS=[settings.STATIC_ROOT]):
|
||||||
self.assertEqual(check_finders(None), [
|
self.assertEqual(check_finders(None), [
|
||||||
Error(
|
Error(
|
||||||
'The STATICFILES_DIRS setting should not contain the '
|
'The STATICFILES_DIRS setting should not contain the '
|
||||||
|
@ -66,8 +71,8 @@ class FindersCheckTests(SimpleTestCase):
|
||||||
)
|
)
|
||||||
])
|
])
|
||||||
|
|
||||||
@override_settings(STATICFILES_DIRS=[('prefix', settings.STATIC_ROOT)])
|
|
||||||
def test_dirs_contains_static_root_in_tuple(self):
|
def test_dirs_contains_static_root_in_tuple(self):
|
||||||
|
with self.settings(STATICFILES_DIRS=[('prefix', settings.STATIC_ROOT)]):
|
||||||
self.assertEqual(check_finders(None), [
|
self.assertEqual(check_finders(None), [
|
||||||
Error(
|
Error(
|
||||||
'The STATICFILES_DIRS setting should not contain the '
|
'The STATICFILES_DIRS setting should not contain the '
|
||||||
|
@ -76,12 +81,13 @@ class FindersCheckTests(SimpleTestCase):
|
||||||
)
|
)
|
||||||
])
|
])
|
||||||
|
|
||||||
@override_settings(STATICFILES_DIRS=[('prefix/', '/fake/path')])
|
|
||||||
def test_prefix_contains_trailing_slash(self):
|
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), [
|
self.assertEqual(check_finders(None), [
|
||||||
Error(
|
Error(
|
||||||
"The prefix 'prefix/' in the STATICFILES_DIRS setting must "
|
"The prefix 'prefix/' in the STATICFILES_DIRS setting must "
|
||||||
"not end with a slash.",
|
"not end with a slash.",
|
||||||
id='staticfiles.E003',
|
id='staticfiles.E003',
|
||||||
)
|
),
|
||||||
])
|
])
|
||||||
|
|
Loading…
Reference in New Issue