@@ -4693,6 +4693,33 @@ def tzname(self, dt): return self.tz
46934693 Badtzname .tz = '\ud800 '
46944694 self .assertEqual (t .strftime ("%Z" ), '\ud800 ' )
46954695
4696+ def test_subminute_offset_equality (self ):
4697+ t1 = self .theclass (12 , tzinfo = timezone .utc )
4698+ t2 = self .theclass (12 , 0 , 1 , tzinfo = timezone (timedelta (seconds = 1 )))
4699+ self .assertEqual (t1 , t2 )
4700+ t2 = self .theclass (12 , 0 , 0 , 1 , tzinfo = timezone (timedelta (microseconds = 1 )))
4701+ self .assertEqual (t1 , t2 )
4702+ t2 = self .theclass (11 , 59 , 59 , 999999 , tzinfo = timezone (timedelta (microseconds = - 1 )))
4703+ self .assertEqual (t1 , t2 )
4704+
4705+ def test_subminute_offset_ordering (self ):
4706+ t1 = self .theclass (0 , tzinfo = timezone .utc )
4707+ t2 = self .theclass (0 , tzinfo = timezone (timedelta (microseconds = 1 )))
4708+ self .assertGreater (t1 , t2 )
4709+
4710+ t1 = self .theclass (13 , 59 , 59 , 900000 , tzinfo = timezone (timedelta (hours = 2 )))
4711+ t2 = self .theclass (14 , tzinfo = timezone (timedelta (hours = 2 , microseconds = 900000 )))
4712+ self .assertGreater (t1 , t2 )
4713+
4714+ def test_subminute_offset_hash (self ):
4715+ t1 = self .theclass (12 , tzinfo = timezone .utc )
4716+ t2 = self .theclass (12 , 0 , 1 , tzinfo = timezone (timedelta (seconds = 1 )))
4717+ self .assertEqual (hash (t1 ), hash (t2 ))
4718+ t2 = self .theclass (12 , 0 , 0 , 1 , tzinfo = timezone (timedelta (microseconds = 1 )))
4719+ self .assertEqual (hash (t1 ), hash (t2 ))
4720+ t2 = self .theclass (11 , 59 , 59 , 999999 , tzinfo = timezone (timedelta (microseconds = - 1 )))
4721+ self .assertEqual (hash (t1 ), hash (t2 ))
4722+
46964723 def test_hash_edge_cases (self ):
46974724 # Offsets that overflow a basic time.
46984725 t1 = self .theclass (0 , 1 , 2 , 3 , tzinfo = FixedOffset (1439 , "" ))
0 commit comments