Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions django/contrib/staticfiles/finders.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ def check(self, **kwargs):
"configured correctly."
)

def find(self, path, find_all=False):
"""
Given a relative file path, find an absolute file path.
If the ``find_all`` parameter is False (default) return only the first
found file path; if True, return a list of all found files paths.
"""
raise NotImplementedError(
"subclasses of BaseFinder must provide a find() method"
)

def list(self, ignore_patterns):
"""
Given an optional list of paths to ignore, return a two item iterable
Expand Down
14 changes: 14 additions & 0 deletions tests/staticfiles_tests/test_finders.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@
from .settings import TEST_ROOT


class TestBaseFinder(SimpleTestCase):
def test_find(self):
finder = finders.BaseFinder()
msg = "subclasses of BaseFinder must provide a find() method"
with self.assertRaisesMessage(NotImplementedError, msg):
finder.find("file.txt")

def test_list(self):
finder = finders.BaseFinder()
msg = "subclasses of BaseFinder must provide a list() method"
with self.assertRaisesMessage(NotImplementedError, msg):
finder.list(None)


class TestFinders:
"""
Base finder test mixin.
Expand Down
Loading