File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 1818except ImportError :
1919 _testinternalcapi = None
2020
21- from test .support import skip_if_buggy_ucrt_strfptime
21+ from test .support import skip_if_buggy_ucrt_strfptime , SuppressCrashReport
2222
2323# Max year is only limited by the size of C int.
2424SIZEOF_INT = sysconfig .get_config_var ('SIZEOF_INT' ) or 4
@@ -182,6 +182,17 @@ def test_strftime(self):
182182
183183 self .assertRaises (TypeError , time .strftime , b'%S' , tt )
184184
185+ def test_strftime_invalid_format (self ):
186+ tt = time .gmtime (self .t )
187+ with SuppressCrashReport ():
188+ for i in range (1 , 128 ):
189+ format = ' %' + chr (i )
190+ with self .subTest (format = format ):
191+ try :
192+ time .strftime (format , tt )
193+ except ValueError as exc :
194+ self .assertEqual (str (exc ), 'Invalid format string' )
195+
185196 def test_strftime_special (self ):
186197 tt = time .gmtime (self .t )
187198 s1 = time .strftime ('%c' , tt )
You can’t perform that action at this time.
0 commit comments