Skip to content

Commit 4dbc38d

Browse files
Pauls suggestion to refactor test
1 parent ade347d commit 4dbc38d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Lib/test/datetimetester.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2537,10 +2537,14 @@ def test_strptime(self):
25372537
with self.assertRaises(ValueError): strptime("-000", "%z")
25382538

25392539
def test_strptime_ampm(self):
2540+
dt = datetime(1999, 3, 17, 0, 44, 55, 2, 76, 0)
25402541
for hour in range(0, 24):
25412542
with self.subTest(hour=hour):
2542-
hour_date = (1999, 3, 17, hour, 44, 55, 2, 76, 0)
2543-
self.assertEqual(self.theclass.strptime(_time.strftime("%I %p", hour_date), "%I %p").hour, hour)
2543+
new_dt = dt.replace(hour=hour)
2544+
dt_str = new_dt.strftime("%I %p")
2545+
2546+
self.assertEqual(self.theclass.strptime(dt_str, "%I %p").hour,
2547+
hour)
25442548

25452549
def test_strptime_single_digit(self):
25462550
# bpo-34903: Check that single digit dates and times are allowed.

0 commit comments

Comments
 (0)