1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
Description: datetime does not work with non-constant pytz.timezone
This has always been the case (and is explicitly warned about
in the pytz documentation), but became a test fail when
tzdata 2024b changed 'CET' and similar to aliases.
Also, some of these tests expect all-year UTC+1, not CET,
probably because they were written to work around this pytz issue.
Author: Rebecca N. Palmer <rebecca_palmer@zoho.com>
Bug-Debian: https://bugs.debian.org/1084256
Forwarded: no
--- flask-restful-0.3.10.orig/tests/test_fields.py
+++ flask-restful-0.3.10/tests/test_fields.py
@@ -1,12 +1,12 @@
from decimal import Decimal
from functools import partial
-import pytz
+import zoneinfo
import unittest
from mock import Mock
from flask_restful.fields import MarshallingException
from flask_restful.utils import OrderedDict
from flask_restful import fields
-from datetime import datetime, timedelta, tzinfo
+from datetime import datetime, timedelta, timezone, tzinfo
from flask import Flask, Blueprint
#noinspection PyUnresolvedReferences
from tests import assert_equals
@@ -52,9 +52,9 @@ def test_rfc822_datetime_formatters():
(datetime(2011, 1, 1), "Sat, 01 Jan 2011 00:00:00 -0000"),
(datetime(2011, 1, 1, 23, 59, 59),
"Sat, 01 Jan 2011 23:59:59 -0000"),
- (datetime(2011, 1, 1, 23, 59, 59, tzinfo=pytz.utc),
+ (datetime(2011, 1, 1, 23, 59, 59, tzinfo=timezone.utc),
"Sat, 01 Jan 2011 23:59:59 -0000"),
- (datetime(2011, 1, 1, 23, 59, 59, tzinfo=pytz.timezone('CET')),
+ (datetime(2011, 1, 1, 23, 59, 59, tzinfo=zoneinfo.ZoneInfo('Africa/Lagos')),
"Sat, 01 Jan 2011 22:59:59 -0000")
]
for date_obj, expected in dates:
@@ -68,11 +68,11 @@ def test_iso8601_datetime_formatters():
"2011-01-01T23:59:59"),
(datetime(2011, 1, 1, 23, 59, 59, 1000),
"2011-01-01T23:59:59.001000"),
- (datetime(2011, 1, 1, 23, 59, 59, tzinfo=pytz.utc),
+ (datetime(2011, 1, 1, 23, 59, 59, tzinfo=timezone.utc),
"2011-01-01T23:59:59+00:00"),
- (datetime(2011, 1, 1, 23, 59, 59, 1000, tzinfo=pytz.utc),
+ (datetime(2011, 1, 1, 23, 59, 59, 1000, tzinfo=timezone.utc),
"2011-01-01T23:59:59.001000+00:00"),
- (datetime(2011, 1, 1, 23, 59, 59, tzinfo=pytz.timezone('CET')),
+ (datetime(2011, 1, 1, 23, 59, 59, tzinfo=zoneinfo.ZoneInfo('Africa/Lagos')),
"2011-01-01T23:59:59+01:00")
]
for date_obj, expected in dates:
@@ -363,7 +363,7 @@ class FieldsTestCase(unittest.TestCase):
self.assertEqual("Mon, 22 Aug 2011 20:58:45 -0000", field.output("bar", obj))
def test_rfc822_date_field_with_offset(self):
- obj = {"bar": datetime(2011, 8, 22, 20, 58, 45, tzinfo=pytz.timezone('CET'))}
+ obj = {"bar": datetime(2011, 8, 22, 20, 58, 45, tzinfo=zoneinfo.ZoneInfo('Africa/Lagos'))}
field = fields.DateTime()
self.assertEqual("Mon, 22 Aug 2011 19:58:45 -0000", field.output("bar", obj))
@@ -373,7 +373,7 @@ class FieldsTestCase(unittest.TestCase):
self.assertEqual("2011-08-22T20:58:45", field.output("bar", obj))
def test_iso8601_date_field_with_offset(self):
- obj = {"bar": datetime(2011, 8, 22, 20, 58, 45, tzinfo=pytz.timezone('CET'))}
+ obj = {"bar": datetime(2011, 8, 22, 20, 58, 45, tzinfo=zoneinfo.ZoneInfo('Africa/Lagos'))}
field = fields.DateTime(dt_format='iso8601')
self.assertEqual("2011-08-22T20:58:45+01:00", field.output("bar", obj))
|