bpo-35066: Make trailing percent test more portable. (GH-15907) · python/cpython@0553369
@@ -1411,15 +1411,20 @@ def test_strftime(self):
14111411t.strftime("%f")
1412141214131413def test_strftime_trailing_percent(self):
1414-# bpo-35066: make sure trailing '%' doesn't cause
1415-# datetime's strftime to complain
1414+# bpo-35066: Make sure trailing '%' doesn't cause datetime's strftime to
1415+# complain. Different libcs have different handling of trailing
1416+# percents, so we simply check datetime's strftime acts the same as
1417+# time.strftime.
14161418t = self.theclass(2005, 3, 2)
14171419try:
14181420_time.strftime('%')
14191421except ValueError:
14201422self.skipTest('time module does not support trailing %')
1421-self.assertEqual(t.strftime('%'), '%')
1422-self.assertEqual(t.strftime("m:%m d:%d y:%y %"), "m:03 d:02 y:05 %")
1423+self.assertEqual(t.strftime('%'), _time.strftime('%', t.timetuple()))
1424+self.assertEqual(
1425+t.strftime("m:%m d:%d y:%y %"),
1426+_time.strftime("m:03 d:02 y:05 %", t.timetuple()),
1427+ )
1423142814241429def test_format(self):
14251430dt = self.theclass(2007, 9, 10)