Skip to content

Commit 677b8a5

Browse files
Use subTest, move to test_stftime_special
1 parent 1c23f5a commit 677b8a5

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

Lib/test/datetimetester.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4084,13 +4084,6 @@ def test_strftime(self):
40844084
# A naive object replaces %z, %:z and %Z with empty strings.
40854085
self.assertEqual(t.strftime("'%z' '%:z' '%Z'"), "'' '' ''")
40864086

4087-
# gh-152305: the year directives must not raise on a time (1900-01-01).
4088-
t1230 = self.theclass(12, 30)
4089-
self.assertEqual(t1230.strftime('%Y'), '1900')
4090-
self.assertEqual(t1230.strftime('%G'), '1900')
4091-
self.assertEqual(t1230.strftime('%C'), '19')
4092-
self.assertEqual(t1230.strftime('%F'), '1900-01-01')
4093-
40944087
# bpo-34482: Check that surrogates don't cause a crash.
40954088
try:
40964089
t.strftime('%H\ud800%M')
@@ -4126,6 +4119,11 @@ def test_strftime_special(self):
41264119
self.assertEqual(t.strftime('\0'*1000), '\0'*1000)
41274120
self.assertEqual(t.strftime('\0%I%p%Z\0%X'), f'\0{s1}\0{s2}')
41284121
self.assertEqual(t.strftime('%I%p%Z\0%X\0'), f'{s1}\0{s2}\0')
4122+
# gh-152305: the year directives must not raise on a time.
4123+
for directive, expected in (('%Y', '1900'), ('%G', '1900'),
4124+
('%C', '19'), ('%F', '1900-01-01')):
4125+
with self.subTest(directive=directive):
4126+
self.assertEqual(t.strftime(directive), expected)
41294127

41304128
def test_format(self):
41314129
t = self.theclass(1, 2, 3, 4)

0 commit comments

Comments
 (0)