summaryrefslogtreecommitdiffstats
path: root/Lib/test/datetimetester.py
diff options
context:
space:
mode:
authorPaul Ganssle <pganssle@users.noreply.github.com>2018-02-22 20:15:32 (GMT)
committerAlexander Belopolsky <abalkin@users.noreply.github.com>2018-02-22 20:15:32 (GMT)
commita049f5790e38fe1b1ba1d4c10ed5ab35150806fa (patch)
tree2c1b85c4c2e62535162de9ed6929d74c5463cffe /Lib/test/datetimetester.py
parent48e8c82fc63d2ddcddce8aa637a892839b551619 (diff)
downloadcpython-a049f5790e38fe1b1ba1d4c10ed5ab35150806fa.zip
cpython-a049f5790e38fe1b1ba1d4c10ed5ab35150806fa.tar.gz
cpython-a049f5790e38fe1b1ba1d4c10ed5ab35150806fa.tar.bz2
Test that new_timezone can return the UTC singleton (gh-5318)
Diffstat (limited to 'Lib/test/datetimetester.py')
-rw-r--r--Lib/test/datetimetester.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py
index 8f9ebdd..436cbea 100644
--- a/Lib/test/datetimetester.py
+++ b/Lib/test/datetimetester.py
@@ -5489,6 +5489,28 @@ class CapiTest(unittest.TestCase):
self.assertEqual(dt1.astimezone(timezone.utc), dt_utc)
+ def test_timezones_offset_zero(self):
+ utc0, utc1, non_utc = _testcapi.get_timezones_offset_zero()
+
+ with self.subTest(testname="utc0"):
+ self.assertIs(utc0, timezone.utc)
+
+ with self.subTest(testname="utc1"):
+ self.assertIs(utc1, timezone.utc)
+
+ with self.subTest(testname="non_utc"):
+ self.assertIsNot(non_utc, timezone.utc)
+
+ non_utc_exp = timezone(timedelta(hours=0), "")
+
+ self.assertEqual(non_utc, non_utc_exp)
+
+ dt1 = datetime(2000, 2, 4, tzinfo=non_utc)
+ dt2 = datetime(2000, 2, 4, tzinfo=non_utc_exp)
+
+ self.assertEqual(dt1, dt2)
+ self.assertEqual(dt1.tzname(), dt2.tzname())
+
def test_check_date(self):
class DateSubclass(date):
pass