@@ -1591,15 +1591,30 @@ def test_strftime(self):
15911591 self .assertEqual (t .strftime ('x' * 1000 ), 'x' * 1000 ) # SF bug #1556784
15921592
15931593 # See gh-137165
1594- if platform .system () in (' Darwin' , ' iOS' , ' FreeBSD' ):
1594+ if platform .system () in (" Darwin" , " iOS" , " FreeBSD" ):
15951595 self .assertEqual (t .strftime ("m:%-m d:%-d y:%-y" ), "m:3 d:2 y:05" )
15961596 else :
1597- if platform .system () == ' Windows' :
1597+ if platform .system () == " Windows" :
15981598 self .assertEqual (t .strftime ("m:%#m d:%#d y:%#y" ), "m:3 d:2 y:5" )
15991599 self .assertEqual (t .strftime ("m:%-m d:%-d y:%-y" ), "m:3 d:2 y:5" )
16001600
16011601 self .assertEqual (t .strftime ("%-j. %-U. %-W. %-V." ), "61. 9. 9. 9." )
16021602
1603+ if platform .system () in ("Windows" , "Android" ):
1604+ # invalid %-format specifiers must raise ValueError
1605+ self .assertRaises (ValueError , t .strftime , "%-1" )
1606+ self .assertRaises (ValueError , t .strftime , "%--" )
1607+ self .assertRaises (ValueError , t .strftime , "%-p" )
1608+ self .assertRaises (ValueError , t .strftime , "%-#" )
1609+ elif platform .system () in ("Darwin" , "iOS" , "FreeBSD" ):
1610+ self .assertEqual (t .strftime ("%-1" ), "1" )
1611+ self .assertEqual (t .strftime ("%--" ), "-" )
1612+ self .assertEqual (t .strftime ("%-#" ), "#" )
1613+ else :
1614+ self .assertEqual (t .strftime ("%-1" ), "%-1" )
1615+ self .assertEqual (t .strftime ("%--" ), "%--" )
1616+ self .assertEqual (t .strftime ("%-#" ), "%-#" )
1617+
16031618 self .assertRaises (TypeError , t .strftime ) # needs an arg
16041619 self .assertRaises (TypeError , t .strftime , "one" , "two" ) # too many args
16051620 self .assertRaises (TypeError , t .strftime , 42 ) # arg wrong type
0 commit comments