From 74326128d18e26da6ce007b543e981662aa9777f Mon Sep 17 00:00:00 2001 From: Hassan Abouelela Date: Fri, 19 Aug 2022 02:00:23 +0400 Subject: 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 --- manage.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'manage.py') diff --git a/manage.py b/manage.py index 697960c6..37fb141f 100755 --- a/manage.py +++ b/manage.py @@ -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: -- cgit v1.2.3 From 182b7e5c2479ea7c35191e99656f82642d8aa24c Mon Sep 17 00:00:00 2001 From: wookie184 Date: Sat, 19 Nov 2022 13:57:37 +0000 Subject: Fix error when invoking manage.py with no commands --- manage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'manage.py') diff --git a/manage.py b/manage.py index 37fb141f..afca6121 100755 --- a/manage.py +++ b/manage.py @@ -195,7 +195,7 @@ def main() -> None: # Pass any others directly to standard management commands else: - _static_build = "distill" in sys.argv[1] + _static_build = len(sys.argv) > 1 and "distill" in sys.argv[1] if _static_build: # Build a static version of the site with no databases and API support -- cgit v1.2.3