Skip to content

Commit 7432612

Browse files
Ignore Whitenoise's Static Directory Warning
Whitenoise raises a warning when the static content folder does not exist, which is the case during tests in CI. This is not an issue though, and static content does get used properly in tests. Thus, the warning is silenced. Signed-off-by: Hassan Abouelela <[email protected]>
1 parent a2beb05 commit 7432612

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

manage.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import django
88
from django.contrib.auth import get_user_model
99
from django.core.management import call_command, execute_from_command_line
10+
from django.test.utils import ignore_warnings
1011

1112
DEFAULT_ENVS = {
1213
"DJANGO_SETTINGS_MODULE": "pydis_site.settings",
@@ -154,7 +155,16 @@ def run_server(self) -> None:
154155
def run_tests(self) -> None:
155156
"""Prepare and run the test suite."""
156157
self.prepare_environment()
157-
call_command(*sys.argv[1:])
158+
# The whitenoise package expects a staticfiles directory to exist during startup,
159+
# else it raises a warning. This is fine under normal application, but during
160+
# tests, staticfiles are not, and do not need to be generated.
161+
# The following line suppresses the warning.
162+
# Reference: https://github.com/evansd/whitenoise/issues/215
163+
with ignore_warnings(
164+
message=r"No directory at: .*staticfiles",
165+
module="whitenoise.base",
166+
):
167+
call_command(*sys.argv[1:])
158168

159169

160170
def clean_up_static_files(build_folder: Path) -> None:

0 commit comments

Comments
 (0)