mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-29 04:54:00 +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.field = serializers.DateTimeField()
|
||||||
cls.kolkata = pytz.timezone('Asia/Kolkata')
|
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):
|
def test_default_timezone(self):
|
||||||
assert self.field.default_timezone() == utc
|
self.assertUTC(self.field.default_timezone())
|
||||||
|
|
||||||
def test_current_timezone(self):
|
def test_current_timezone(self):
|
||||||
assert self.field.default_timezone() == utc
|
self.assertUTC(self.field.default_timezone())
|
||||||
activate(self.kolkata)
|
activate(self.kolkata)
|
||||||
assert self.field.default_timezone() == self.kolkata
|
assert self.field.default_timezone() == self.kolkata
|
||||||
deactivate()
|
deactivate()
|
||||||
assert self.field.default_timezone() == utc
|
self.assertUTC(self.field.default_timezone())
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(pytz is None, reason='pytz not installed')
|
@pytest.mark.skipif(pytz is None, reason='pytz not installed')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user