@@ -2125,6 +2125,7 @@ def test_fromisocalendar_type_errors(self):
21252125 self .theclass .fromisocalendar (* isocal )
21262126
21272127 def test_strftime_strptime_roundtrip_concerning_locale_specific_year (self ):
2128+ # gh-124529
21282129 concerned_formats = '%c' , '%x'
21292130
21302131 def run_subtest ():
@@ -2138,38 +2139,40 @@ def run_subtest():
21382139 try :
21392140 parsed = self .theclass .strptime (formatted , fmt )
21402141 except ValueError as exc :
2141- # gh-124529
21422142 self .fail (f"{ fail_msg } ; parsing error: { exc !r} " )
21432143 self .assertEqual (parsed , expected , fail_msg )
21442144
2145- sample = self .theclass .strptime (f '1999-03-17 ' , '%Y-%m-%d ' )
2145+ sample = self .theclass .strptime ('1999' , '%Y' )
21462146 for fmt in concerned_formats :
21472147 with self .subTest (fmt = fmt ):
21482148 sample_str = sample .strftime (fmt )
21492149 if '1999' in sample_str :
21502150 for year in [
2151- 1 , 9 , 10 , 99 , 100 , 999 , # <- gh-124529
21522151 1000 , 1410 , 1989 , 2024 , 2095 , 9999 ,
2152+ # gh-124529:
2153+ 1 , 9 , 10 , 99 , 100 , 999 ,
21532154 ]:
21542155 run_subtest ()
21552156 elif '99' in sample_str :
21562157 for year in [
2157- 1969 , 1999 ,
2158- 2000 , 2001 , 2009 , # <- gh-124529
2159- 2068 ,
2158+ 1969 , 1999 , 2068 ,
2159+ # gh-124529:
2160+ 2000 , 2001 , 2009 ,
21602161 ]:
21612162 run_subtest ()
21622163 else :
2163- self .fail (f"it seems that { sample .strftime (fmt )= } "
2164- f"does not include year={ sample .year !r} in "
2165- f"any expected format (is there something "
2166- f"severely wrong with current locale?)" )
2164+ self .fail (f"it seems that sample.strftime({ fmt !r} )="
2165+ f"{ sample_str !r} does not include year="
2166+ f"{ sample .year !r} in any expected format "
2167+ f"(is there something severely wrong with "
2168+ f"current locale?)" )
21672169
21682170 def test_strptime_accepting_locale_specific_year_with_fewer_digits (self ):
2171+ # gh-124529
21692172 concerned_formats = '%c' , '%x'
21702173
21712174 def run_subtest ():
2172- input_str = sample_str .replace (sample_digits , year_digits )
2175+ input_str = sample_str .replace (sample_year_digits , year_digits )
21732176 reason = (f"test strptime accepting locale-specific "
21742177 f"year representation with fewer digits "
21752178 f"- for { fmt = } and { input_str = } ({ year = } )" )
@@ -2179,27 +2182,27 @@ def run_subtest():
21792182 try :
21802183 parsed = self .theclass .strptime (input_str , fmt )
21812184 except ValueError as exc :
2182- # gh-124529
21832185 self .fail (f"{ fail_msg } ; parsing error: { exc !r} " )
21842186 self .assertEqual (parsed , expected , fail_msg )
21852187
2186- sample = self .theclass .strptime (f '1999-03-17 ' , '%Y-%m-%d ' )
2188+ sample = self .theclass .strptime ('1999' , '%Y' )
21872189 for fmt in concerned_formats :
21882190 with self .subTest (fmt = fmt ):
21892191 sample_str = sample .strftime (fmt )
2190- if (sample_digits := '1999' ) in sample_str :
2192+ if (sample_year_digits := '1999' ) in sample_str :
21912193 for year in [1 , 9 , 10 , 99 , 100 , 999 ]:
21922194 year_digits = str (year )
21932195 run_subtest ()
2194- elif (sample_digits := '99' ) in sample_str :
2196+ elif (sample_year_digits := '99' ) in sample_str :
21952197 for year in [2000 , 2001 , 2009 ]:
21962198 year_digits = str (year - 2000 )
21972199 run_subtest ()
21982200 else :
2199- self .fail (f"it seems that { sample .strftime (fmt )= } "
2200- f"does not include year={ sample .year !r} in "
2201- f"any expected format (is there something "
2202- f"severely wrong with current locale?)" )
2201+ self .fail (f"it seems that sample.strftime({ fmt !r} )="
2202+ f"{ sample_str !r} does not include year="
2203+ f"{ sample .year !r} in any expected format "
2204+ f"(is there something severely wrong with "
2205+ f"current locale?)" )
22032206
22042207
22052208#############################################################################
0 commit comments