Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 19, 2022
1 parent e5f300b commit 124f547
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
7 changes: 5 additions & 2 deletions src/whitenoise/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,18 @@ def process_request(self, request):

if settings.DEBUG and request.path.startswith(settings.STATIC_URL):
from django.contrib.staticfiles.finders import get_finders

finders = get_finders()
app_dirs = []
for finder in finders:
for storage in finder.storages.values():
app_dirs.append(storage.location)
app_dirs = "\n ".join(sorted(app_dirs))
raise MissingFileError(f"""{request.path} not found. Searched these paths:
raise MissingFileError(
f"""{request.path} not found. Searched these paths:
{app_dirs}""")
{app_dirs}"""
)

@staticmethod
def serve(static_file, request):
Expand Down
4 changes: 1 addition & 3 deletions tests/django_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@ def avoid_django_default_welcome_page():
pass


urlpatterns = [
path('', avoid_django_default_welcome_page)
]
urlpatterns = [path("", avoid_django_default_welcome_page)]
6 changes: 3 additions & 3 deletions tests/test_django_whitenoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,15 @@ def test_relative_static_url(server, static_files, _collect_static):


def test_404_in_prod(server):
response = server.get(settings.STATIC_URL + 'garbage')
response = server.get(settings.STATIC_URL + "garbage")
assert response.status_code == 404


@override_settings(DEBUG=True)
def test_error_message(server):
response = server.get(settings.STATIC_URL + 'garbage')
response = server.get(settings.STATIC_URL + "garbage")
print(response.content.decode())
app_dirs = Path(__file__).parent / 'test_files' / 'static'
app_dirs = Path(__file__).parent / "test_files" / "static"

expected = f"""{settings.STATIC_URL + 'garbage'} not found. Searched these paths:
Expand Down

0 comments on commit 124f547

Please sign in to comment.