@@ -406,34 +406,41 @@ def test_offset(self):
406406 (* _ , offset ), _ , offset_fraction = _strptime ._strptime ("-013030.000001" , "%z" )
407407 self .assertEqual (offset , - (one_hour + half_hour + half_minute ))
408408 self .assertEqual (offset_fraction , - 1 )
409- (* _ , offset ), _ , offset_fraction = _strptime ._strptime ("+01:00" , "%z" )
410- self .assertEqual (offset , one_hour )
411- self .assertEqual (offset_fraction , 0 )
412- (* _ , offset ), _ , offset_fraction = _strptime ._strptime ("-01:30" , "%z" )
413- self .assertEqual (offset , - (one_hour + half_hour ))
414- self .assertEqual (offset_fraction , 0 )
415- (* _ , offset ), _ , offset_fraction = _strptime ._strptime ("-01:30:30" , "%z" )
416- self .assertEqual (offset , - (one_hour + half_hour + half_minute ))
417- self .assertEqual (offset_fraction , 0 )
418- (* _ , offset ), _ , offset_fraction = _strptime ._strptime ("-01:30:30.000001" , "%z" )
419- self .assertEqual (offset , - (one_hour + half_hour + half_minute ))
420- self .assertEqual (offset_fraction , - 1 )
421- (* _ , offset ), _ , offset_fraction = _strptime ._strptime ("+01:30:30.001" , "%z" )
422- self .assertEqual (offset , one_hour + half_hour + half_minute )
423- self .assertEqual (offset_fraction , 1000 )
424409 (* _ , offset ), _ , offset_fraction = _strptime ._strptime ("Z" , "%z" )
425410 self .assertEqual (offset , 0 )
426411 self .assertEqual (offset_fraction , 0 )
412+ for directive in ("%z" , "%:z" ):
413+ (* _ , offset ), _ , offset_fraction = _strptime ._strptime ("+01:00" ,
414+ directive )
415+ self .assertEqual (offset , one_hour )
416+ self .assertEqual (offset_fraction , 0 )
417+ (* _ , offset ), _ , offset_fraction = _strptime ._strptime ("-01:30" ,
418+ directive )
419+ self .assertEqual (offset , - (one_hour + half_hour ))
420+ self .assertEqual (offset_fraction , 0 )
421+ (* _ , offset ), _ , offset_fraction = _strptime ._strptime ("-01:30:30" ,
422+ directive )
423+ self .assertEqual (offset , - (one_hour + half_hour + half_minute ))
424+ self .assertEqual (offset_fraction , 0 )
425+ (* _ , offset ), _ , offset_fraction = _strptime ._strptime ("-01:30:30.000001" ,
426+ directive )
427+ self .assertEqual (offset , - (one_hour + half_hour + half_minute ))
428+ self .assertEqual (offset_fraction , - 1 )
429+ (* _ , offset ), _ , offset_fraction = _strptime ._strptime ("+01:30:30.001" ,
430+ directive )
431+ self .assertEqual (offset , one_hour + half_hour + half_minute )
432+ self .assertEqual (offset_fraction , 1000 )
427433
428434 def test_bad_offset (self ):
429- with self .assertRaises (ValueError ):
430- _strptime ._strptime ("-01:30:30." , "%z" )
435+ for directive in ("%z" , "%:z" ):
436+ with self .assertRaises (ValueError ):
437+ _strptime ._strptime ("-01:30:30." , directive )
438+ with self .assertRaises (ValueError ):
439+ _strptime ._strptime ("-01:30:30.1234567" , directive )
440+ with self .assertRaises (ValueError ):
441+ _strptime ._strptime ("-01:30:30:123456" , directive )
431442 with self .assertRaises (ValueError ):
432443 _strptime ._strptime ("-0130:30" , "%z" )
433- with self .assertRaises (ValueError ):
434- _strptime ._strptime ("-01:30:30.1234567" , "%z" )
435- with self .assertRaises (ValueError ):
436- _strptime ._strptime ("-01:30:30:123456" , "%z" )
437444 with self .assertRaises (ValueError ) as err :
438445 _strptime ._strptime ("-01:3030" , "%z" )
439446 self .assertEqual ("Inconsistent use of : in -01:3030" , str (err .exception ))
0 commit comments