@@ -1807,7 +1807,7 @@ def test_bool(self):
18071807 self .assertTrue (self .theclass .min )
18081808 self .assertTrue (self .theclass .max )
18091809
1810- def test_strftime_y2k (self ):
1810+ def check_strftime_y2k (self , specifier ):
18111811 # Test that years less than 1000 are 0-padded; note that the beginning
18121812 # of an ISO 8601 year may fall in an ISO week of the year before, and
18131813 # therefore needs an offset of -1 when formatting with '%G'.
@@ -1821,22 +1821,28 @@ def test_strftime_y2k(self):
18211821 (1000 , 0 ),
18221822 (1970 , 0 ),
18231823 )
1824- specifiers = 'YG'
1825- if _time .strftime ('%F' , (1900 , 1 , 1 , 0 , 0 , 0 , 0 , 1 , 0 )) == '1900-01-01' :
1826- specifiers += 'FC'
18271824 for year , g_offset in dataset :
1828- for specifier in specifiers :
1829- with self .subTest (year = year , specifier = specifier ):
1830- d = self .theclass (year , 1 , 1 )
1831- if specifier == 'G' :
1832- year += g_offset
1833- if specifier == 'C' :
1834- expected = f"{ year // 100 :02d} "
1835- else :
1836- expected = f"{ year :04d} "
1837- if specifier == 'F' :
1838- expected += f"-01-01"
1839- self .assertEqual (d .strftime (f"%{ specifier } " ), expected )
1825+ with self .subTest (year = year , specifier = specifier ):
1826+ d = self .theclass (year , 1 , 1 )
1827+ if specifier == 'G' :
1828+ year += g_offset
1829+ if specifier == 'C' :
1830+ expected = f"{ year // 100 :02d} "
1831+ else :
1832+ expected = f"{ year :04d} "
1833+ if specifier == 'F' :
1834+ expected += f"-01-01"
1835+ self .assertEqual (d .strftime (f"%{ specifier } " ), expected )
1836+
1837+ def test_strftime_y2k (self ):
1838+ self .check_strftime_y2k ('Y' )
1839+ self .check_strftime_y2k ('G' )
1840+
1841+ def test_strftime_y2k_c99 (self ):
1842+ # CPython requires C11; specifiers new in C99 must work.
1843+ # (Other implementations may want to disable this test.)
1844+ self .check_strftime_y2k ('F' )
1845+ self .check_strftime_y2k ('C' )
18401846
18411847 def test_replace (self ):
18421848 cls = self .theclass
0 commit comments