summaryrefslogtreecommitdiff
path: root/tests/staticfiles_tests/test_finders.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_finders.py
parentf68fa8b45dfac545cfc4111d4e52804c86db68d3 (diff)
Refs #33476 -- Reformatted code with Black.
Diffstat (limited to 'tests/staticfiles_tests/test_finders.py')
-rw-r--r--tests/staticfiles_tests/test_finders.py53
1 files changed, 32 insertions, 21 deletions
diff --git a/tests/staticfiles_tests/test_finders.py b/tests/staticfiles_tests/test_finders.py
index 9d5707cc2d..9f2509d533 100644
--- a/tests/staticfiles_tests/test_finders.py
+++ b/tests/staticfiles_tests/test_finders.py
@@ -17,6 +17,7 @@ class TestFinders:
path(s) they find can differ. Compare them using os.path.normcase() to
avoid false negatives.
"""
+
def test_find_first(self):
src, dst = self.find_first
found = self.finder.find(src)
@@ -34,76 +35,86 @@ class TestFileSystemFinder(TestFinders, StaticFilesTestCase):
"""
Test FileSystemFinder.
"""
+
def setUp(self):
super().setUp()
self.finder = finders.FileSystemFinder()
- test_file_path = os.path.join(TEST_ROOT, 'project', 'documents', 'test', 'file.txt')
- self.find_first = (os.path.join('test', 'file.txt'), test_file_path)
- self.find_all = (os.path.join('test', 'file.txt'), [test_file_path])
+ test_file_path = os.path.join(
+ TEST_ROOT, "project", "documents", "test", "file.txt"
+ )
+ self.find_first = (os.path.join("test", "file.txt"), test_file_path)
+ self.find_all = (os.path.join("test", "file.txt"), [test_file_path])
class TestAppDirectoriesFinder(TestFinders, StaticFilesTestCase):
"""
Test AppDirectoriesFinder.
"""
+
def setUp(self):
super().setUp()
self.finder = finders.AppDirectoriesFinder()
- test_file_path = os.path.join(TEST_ROOT, 'apps', 'test', 'static', 'test', 'file1.txt')
- self.find_first = (os.path.join('test', 'file1.txt'), test_file_path)
- self.find_all = (os.path.join('test', 'file1.txt'), [test_file_path])
+ test_file_path = os.path.join(
+ TEST_ROOT, "apps", "test", "static", "test", "file1.txt"
+ )
+ self.find_first = (os.path.join("test", "file1.txt"), test_file_path)
+ self.find_all = (os.path.join("test", "file1.txt"), [test_file_path])
class TestDefaultStorageFinder(TestFinders, StaticFilesTestCase):
"""
Test DefaultStorageFinder.
"""
+
def setUp(self):
super().setUp()
self.finder = finders.DefaultStorageFinder(
- storage=storage.StaticFilesStorage(location=settings.MEDIA_ROOT))
- test_file_path = os.path.join(settings.MEDIA_ROOT, 'media-file.txt')
- self.find_first = ('media-file.txt', test_file_path)
- self.find_all = ('media-file.txt', [test_file_path])
+ storage=storage.StaticFilesStorage(location=settings.MEDIA_ROOT)
+ )
+ test_file_path = os.path.join(settings.MEDIA_ROOT, "media-file.txt")
+ self.find_first = ("media-file.txt", test_file_path)
+ self.find_all = ("media-file.txt", [test_file_path])
@override_settings(
- STATICFILES_FINDERS=['django.contrib.staticfiles.finders.FileSystemFinder'],
- STATICFILES_DIRS=[os.path.join(TEST_ROOT, 'project', 'documents')],
+ STATICFILES_FINDERS=["django.contrib.staticfiles.finders.FileSystemFinder"],
+ STATICFILES_DIRS=[os.path.join(TEST_ROOT, "project", "documents")],
)
class TestMiscFinder(SimpleTestCase):
"""
A few misc finder tests.
"""
+
def test_get_finder(self):
- self.assertIsInstance(finders.get_finder(
- 'django.contrib.staticfiles.finders.FileSystemFinder'),
- finders.FileSystemFinder)
+ self.assertIsInstance(
+ finders.get_finder("django.contrib.staticfiles.finders.FileSystemFinder"),
+ finders.FileSystemFinder,
+ )
def test_get_finder_bad_classname(self):
with self.assertRaises(ImportError):
- finders.get_finder('django.contrib.staticfiles.finders.FooBarFinder')
+ finders.get_finder("django.contrib.staticfiles.finders.FooBarFinder")
def test_get_finder_bad_module(self):
with self.assertRaises(ImportError):
- finders.get_finder('foo.bar.FooBarFinder')
+ finders.get_finder("foo.bar.FooBarFinder")
def test_cache(self):
finders.get_finder.cache_clear()
for n in range(10):
- finders.get_finder('django.contrib.staticfiles.finders.FileSystemFinder')
+ finders.get_finder("django.contrib.staticfiles.finders.FileSystemFinder")
cache_info = finders.get_finder.cache_info()
self.assertEqual(cache_info.hits, 9)
self.assertEqual(cache_info.currsize, 1)
def test_searched_locations(self):
- finders.find('spam')
+ finders.find("spam")
self.assertEqual(
finders.searched_locations,
- [os.path.join(TEST_ROOT, 'project', 'documents')]
+ [os.path.join(TEST_ROOT, "project", "documents")],
)
- @override_settings(MEDIA_ROOT='')
+ @override_settings(MEDIA_ROOT="")
def test_location_empty(self):
msg = (
"The storage backend of the staticfiles finder "