diff options
author | Zackery Spytz <zspytz@gmail.com> | 2020-09-23 18:43:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-23 18:43:45 (GMT) |
commit | 2e4dd336e5b50fd30947fdecb605ddcd71f7f6f5 (patch) | |
tree | 7b8e1b98c94d77ffcdcfc61645c6b40f5ebd44ab /Lib/test | |
parent | 9c4eac7f02ddcf32fc1cdaf7c08c37fe9718c1fb (diff) | |
download | cpython-2e4dd336e5b50fd30947fdecb605ddcd71f7f6f5.zip cpython-2e4dd336e5b50fd30947fdecb605ddcd71f7f6f5.tar.gz cpython-2e4dd336e5b50fd30947fdecb605ddcd71f7f6f5.tar.bz2 |
bpo-30155: Add macros to get tzinfo from datetime instances (GH-21633)
Add PyDateTime_DATE_GET_TZINFO() and PyDateTime_TIME_GET_TZINFO()
macros.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/datetimetester.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py index 520a51d..8b61c26 100644 --- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -5991,30 +5991,36 @@ class CapiTest(unittest.TestCase): for klass in [datetime, DateTimeSubclass]: for args in [(1993, 8, 26, 22, 12, 55, 99999), - (1993, 8, 26, 22, 12, 55, 99999)]: + (1993, 8, 26, 22, 12, 55, 99999, + timezone.utc)]: d = klass(*args) with self.subTest(cls=klass, date=args): - hour, minute, second, microsecond = _testcapi.PyDateTime_DATE_GET(d) + hour, minute, second, microsecond, tzinfo = \ + _testcapi.PyDateTime_DATE_GET(d) self.assertEqual(hour, d.hour) self.assertEqual(minute, d.minute) self.assertEqual(second, d.second) self.assertEqual(microsecond, d.microsecond) + self.assertIs(tzinfo, d.tzinfo) def test_PyDateTime_TIME_GET(self): class TimeSubclass(time): pass for klass in [time, TimeSubclass]: - for args in [(12, 30, 20, 10), (12, 30, 20, 10)]: + for args in [(12, 30, 20, 10), + (12, 30, 20, 10, timezone.utc)]: d = klass(*args) with self.subTest(cls=klass, date=args): - hour, minute, second, microsecond = _testcapi.PyDateTime_TIME_GET(d) + hour, minute, second, microsecond, tzinfo = \ + _testcapi.PyDateTime_TIME_GET(d) self.assertEqual(hour, d.hour) self.assertEqual(minute, d.minute) self.assertEqual(second, d.second) self.assertEqual(microsecond, d.microsecond) + self.assertIs(tzinfo, d.tzinfo) def test_timezones_offset_zero(self): utc0, utc1, non_utc = _testcapi.get_timezones_offset_zero() |