From 70ed89eff9632ed641df76e1b04b915d3d4d2c4b Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Tue, 25 Mar 2025 14:49:28 -0700 Subject: [PATCH] tests: django: Fix a warning related timezone settings The warning is: RemovedInDjango50Warning: The default value of USE_TZ will change from False to True in Django 5.0. Set USE_TZ to False in your project settings if you want to keep the current default behavior. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/tests/data/django_test_settings.py | 4 ++++ plinth/tests/test_notification.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plinth/tests/data/django_test_settings.py b/plinth/tests/data/django_test_settings.py index 1cc2f15a3..0f742f4e3 100644 --- a/plinth/tests/data/django_test_settings.py +++ b/plinth/tests/data/django_test_settings.py @@ -56,3 +56,7 @@ TEMPLATES = [{ 'APP_DIRS': True, 'DIRS': ['plinth/tests/data/templates/'], }] + +TIME_ZONE = 'UTC' + +USE_TZ = True diff --git a/plinth/tests/test_notification.py b/plinth/tests/test_notification.py index 6af90bc7f..cd72755c0 100644 --- a/plinth/tests/test_notification.py +++ b/plinth/tests/test_notification.py @@ -386,7 +386,7 @@ def test_display_context(gettext, note, user, rf): assert context_note['actions'] == expected_actions assert context_note['data'] == expected_data assert note.data == data - now = datetime.datetime.now() + now = datetime.datetime.now(datetime.timezone.utc) assert (now - context_note['created_time']).seconds < 60 assert (now - context_note['last_update_time']).seconds < 60 assert context_note['user'] == 'test-user'