mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-25 11:04:02 +03:00
Fixed TestDefaultTZDateTimeField to allow multiple tzinfo implementations.
zoneinfo was made the default time zone implementation in
306607d5b9
.
This commit is contained in:
parent
19b6091554
commit
f46c33e4e2
|
@ -1464,15 +1464,24 @@ class TestDefaultTZDateTimeField(TestCase):
|
|||
cls.field = serializers.DateTimeField()
|
||||
cls.kolkata = pytz.timezone('Asia/Kolkata')
|
||||
|
||||
def assertUTC(self, tzinfo):
|
||||
"""
|
||||
Check UTC for datetime.timezone, ZoneInfo, and pytz tzinfo instances.
|
||||
"""
|
||||
assert (
|
||||
tzinfo is utc or
|
||||
(getattr(tzinfo, "key", None) or getattr(tzinfo, "zone", None)) == "UTC"
|
||||
)
|
||||
|
||||
def test_default_timezone(self):
|
||||
assert self.field.default_timezone() == utc
|
||||
self.assertUTC(self.field.default_timezone())
|
||||
|
||||
def test_current_timezone(self):
|
||||
assert self.field.default_timezone() == utc
|
||||
self.assertUTC(self.field.default_timezone())
|
||||
activate(self.kolkata)
|
||||
assert self.field.default_timezone() == self.kolkata
|
||||
deactivate()
|
||||
assert self.field.default_timezone() == utc
|
||||
self.assertUTC(self.field.default_timezone())
|
||||
|
||||
|
||||
@pytest.mark.skipif(pytz is None, reason='pytz not installed')
|
||||
|
|
Loading…
Reference in New Issue
Block a user