diff options
author | 2022-08-19 02:00:23 +0400 | |
---|---|---|
committer | 2022-09-17 23:06:44 +0400 | |
commit | 74326128d18e26da6ce007b543e981662aa9777f (patch) | |
tree | 2af72856a5c9cd54bc3a9d24c3f242f0eeca53e5 /manage.py | |
parent | Enable Python Warnings In Tests (diff) |
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]>
Diffstat (limited to 'manage.py')
-rwxr-xr-x | manage.py | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -7,6 +7,7 @@ from pathlib import Path import django from django.contrib.auth import get_user_model from django.core.management import call_command, execute_from_command_line +from django.test.utils import ignore_warnings DEFAULT_ENVS = { "DJANGO_SETTINGS_MODULE": "pydis_site.settings", @@ -154,7 +155,16 @@ class SiteManager: def run_tests(self) -> None: """Prepare and run the test suite.""" self.prepare_environment() - call_command(*sys.argv[1:]) + # The whitenoise package expects a staticfiles directory to exist during startup, + # else it raises a warning. This is fine under normal application, but during + # tests, staticfiles are not, and do not need to be generated. + # The following line suppresses the warning. + # Reference: https://github.com/evansd/whitenoise/issues/215 + with ignore_warnings( + message=r"No directory at: .*staticfiles", + module="whitenoise.base", + ): + call_command(*sys.argv[1:]) def clean_up_static_files(build_folder: Path) -> None: |