]> granicus.if.org Git - python/commitdiff
Added tests that conversion to our own timezone is always an identity,
authorTim Peters <tim.peters@gmail.com>
Mon, 30 Dec 2002 17:37:30 +0000 (17:37 +0000)
committerTim Peters <tim.peters@gmail.com>
Mon, 30 Dec 2002 17:37:30 +0000 (17:37 +0000)
and that conversion to "timezone" None is the same as stripping the
tzinfo member.

Lib/test/test_datetime.py

index 3f41dda38ac8a59b44a762a94d488d769cf25f5e..264d75c8f1888b2b0f8759c3fa5d3ae5700ede21 100644 (file)
@@ -2592,6 +2592,13 @@ class TestTimezoneConversions(unittest.TestCase):
 
             for during in dston, dston + delta, dstoff - delta:
                 self.assertEqual(during.dst(), HOUR)
+
+                # Conversion to our own timezone is always an identity.
+                self.assertEqual(during.astimezone(tz), during)
+                # Conversion to None is always the same as stripping tzinfo.
+                self.assertEqual(during.astimezone(None),
+                                 during.replace(tzinfo=None))
+
                 asutc = during.astimezone(utc)
                 there_and_back = asutc.astimezone(tz)
 
@@ -2649,6 +2656,12 @@ class TestTimezoneConversions(unittest.TestCase):
                 there_and_back = outside.astimezone(utc).astimezone(tz)
                 self.assertEqual(outside, there_and_back)
 
+                # Conversion to our own timezone is always an identity.
+                self.assertEqual(outside.astimezone(tz), outside)
+                # Conversion to None is always the same as stripping tzinfo.
+                self.assertEqual(outside.astimezone(None),
+                                 outside.replace(tzinfo=None))
+
     def test_easy(self):
         # Despite the name of this test, the endcases are excruciating.
         self.convert_between_tz_and_utc(Eastern, utc_real)