@@ -2890,6 +2890,16 @@ def test_strptime(self):
28902890 strptime ("-00:02:01.000003" , "%z" ).utcoffset (),
28912891 - timedelta (minutes = 2 , seconds = 1 , microseconds = 3 )
28922892 )
2893+
2894+ # Test %F
2895+ inputs = [
2896+ (self .theclass (2025 , 3 , 23 , 13 , 2 , 47 , 197000 ), "2025-03-23 13:02:47.197" , "%Y-%m-%d %H:%M:%S%F" ),
2897+ (self .theclass (2025 , 3 , 23 , 13 , 2 , 47 ), "2025-03-23 13:02:47" , "%Y-%m-%d %H:%M:%S%F" ),
2898+ ]
2899+ for expected , string , format in inputs :
2900+ with self .subTest (expected = expected , string = string , format = format ):
2901+ self .assertEqual (expected , self .theclass .strptime (string , format ))
2902+
28932903 # Only local timezone and UTC are supported
28942904 for tzseconds , tzname in ((0 , 'UTC' ), (0 , 'GMT' ),
28952905 (- _time .timezone , _time .tzname [0 ])):
@@ -3858,6 +3868,15 @@ def test_strftime(self):
38583868 # A naive object replaces %z, %:z and %Z with empty strings.
38593869 self .assertEqual (t .strftime ("'%z' '%:z' '%Z'" ), "'' '' ''" )
38603870
3871+ # Test %F
3872+ inputs = [
3873+ (self .theclass (13 , 2 , 47 , 197000 ), "13:02:47.197" , "%H:%M:%S%F" ),
3874+ (self .theclass (13 , 2 , 47 ), "13:02:47" , "%H:%M:%S%F" ),
3875+ ]
3876+ for expected , string , format in inputs :
3877+ with self .subTest (expected = expected , string = string , format = format ):
3878+ self .assertEqual (expected , self .theclass .strptime (string , format ))
3879+
38613880 # bpo-34482: Check that surrogates don't cause a crash.
38623881 try :
38633882 t .strftime ('%H\ud800 %M' )
0 commit comments