diff --git a/django_celery_beat/utils.py b/django_celery_beat/utils.py index 2c003305..5ce3a809 100644 --- a/django_celery_beat/utils.py +++ b/django_celery_beat/utils.py @@ -1,9 +1,10 @@ """Utilities.""" # -- XXX This module must not use translation as that causes # -- a recursive loader import! +import time + from django.conf import settings from django.utils import timezone -import time is_aware = timezone.is_aware # celery schedstate return None will make it not work diff --git a/t/unit/test_utils.py b/t/unit/test_utils.py index 566e9050..4b76a123 100644 --- a/t/unit/test_utils.py +++ b/t/unit/test_utils.py @@ -1,10 +1,12 @@ +import time +from datetime import datetime from unittest import mock + from django.test import TestCase -from datetime import datetime -import time +from django.utils import timezone from django_celery_beat import utils -from django.utils import timezone + class UtilsTest(TestCase): @@ -22,7 +24,7 @@ def test_make_aware_use_tz_naive(self, mock_getattr, mock_is_naive, mock_localti mock_localtime_2.return_value = time.struct_time([2022, 11, 6, 1, 15, 0, 0, 310, 0]) mock_make_aware.return_value = dt - self.assertEquals(utils.make_aware(dt), mock_localtime_2.return_value) + self.assertEqual(utils.make_aware(dt), mock_localtime_2.return_value) mock_localtime_1.assert_not_called() mock_make_aware.assert_called_with(dt, timezone.utc) @@ -43,7 +45,7 @@ def test_make_aware_use_tz_not_naive(self, mock_getattr, mock_is_naive, mock_loc mock_localtime_2.return_value = time.struct_time([2022, 11, 6, 1, 15, 0, 0, 310, 0]) mock_make_aware.return_value = dt - self.assertEquals(utils.make_aware(dt), mock_localtime_2.return_value) + self.assertEqual(utils.make_aware(dt), mock_localtime_2.return_value) mock_localtime_1.assert_not_called() mock_make_aware.assert_not_called() @@ -64,7 +66,7 @@ def test_make_aware_not_use_tz_naive_dst(self, mock_getattr, mock_is_naive, mock mock_localtime_1.return_value = time.struct_time([2022, 11, 6, 1, 15, 0, 0, 310, 1]) mock_make_aware.return_value = dt - self.assertEquals(utils.make_aware(dt), dt) + self.assertEqual(utils.make_aware(dt), dt) mock_localtime_1.assert_called_with() mock_make_aware.assert_called_with(dt, "America/Los_Angeles", is_dst=True) @@ -85,7 +87,7 @@ def test_make_aware_not_use_tz_naive_not_dst(self, mock_getattr, mock_is_naive, mock_localtime_1.return_value = time.struct_time([2022, 11, 6, 1, 15, 0, 0, 310, 0]) mock_make_aware.return_value = dt - self.assertEquals(utils.make_aware(dt), dt) + self.assertEqual(utils.make_aware(dt), dt) mock_localtime_1.assert_called_with() mock_make_aware.assert_called_with(dt, "America/Los_Angeles", is_dst=False) @@ -106,7 +108,7 @@ def test_make_aware_not_use_tz_naive_negative_dst(self, mock_getattr, mock_is_na mock_localtime_1.return_value = time.struct_time([2022, 11, 6, 1, 15, 0, 0, 310, -1]) mock_make_aware.return_value = dt - self.assertEquals(utils.make_aware(dt), dt) + self.assertEqual(utils.make_aware(dt), dt) mock_localtime_1.assert_called_with() mock_make_aware.assert_called_with(dt, "America/Los_Angeles", is_dst=None) @@ -125,7 +127,7 @@ def test_make_aware_not_use_tz_not_naive_dst(self, mock_getattr, mock_is_naive, mock_localtime_1.return_value = time.struct_time([2022, 11, 6, 1, 15, 0, 0, 310, 0]) mock_make_aware.return_value = dt - self.assertEquals(utils.make_aware(dt), dt) + self.assertEqual(utils.make_aware(dt), dt) mock_localtime_1.assert_not_called() mock_make_aware.assert_not_called()