Skip to content

Commit 500552b

Browse files
committed
relocate test methods for %F and %T to TestDate and TestDateTime (resp.) and use self.theclass.strptime
1 parent 46981d1 commit 500552b

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

Lib/test/datetimetester.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,20 +1212,6 @@ def test_strptime_leap_year(self):
12121212
date.strptime('20-03-14', '%y-%m-%d')
12131213
date.strptime('02-29,2024', '%m-%d,%Y')
12141214

1215-
def test_strptime_F_format(self):
1216-
test_date = "2025-10-26"
1217-
self.assertEqual(
1218-
datetime.strptime(test_date, "%F"),
1219-
datetime.strptime(test_date, "%Y-%m-%d")
1220-
)
1221-
1222-
def test_strptime_T_format(self):
1223-
test_time = "15:00:00"
1224-
self.assertEqual(
1225-
datetime.strptime(test_time, "%T"),
1226-
datetime.strptime(test_time, "%H:%M:%S")
1227-
)
1228-
12291215
class SubclassDate(date):
12301216
sub_var = 1
12311217

@@ -2207,6 +2193,12 @@ def test_fromisocalendar_type_errors(self):
22072193
with self.assertRaises(TypeError):
22082194
self.theclass.fromisocalendar(*isocal)
22092195

2196+
def test_strptime_F_format(self):
2197+
test_date = "2025-10-26"
2198+
self.assertEqual(
2199+
self.theclass.strptime(test_date, "%F"),
2200+
self.theclass.strptime(test_date, "%Y-%m-%d")
2201+
)
22102202

22112203
#############################################################################
22122204
# datetime tests
@@ -3794,6 +3786,13 @@ def test_repr_subclass(self):
37943786
td = SubclassDatetime(2010, 10, 2, second=3)
37953787
self.assertEqual(repr(td), "SubclassDatetime(2010, 10, 2, 0, 0, 3)")
37963788

3789+
def test_strptime_T_format(self):
3790+
test_time = "15:00:00"
3791+
self.assertEqual(
3792+
self.theclass.strptime(test_time, "%T"),
3793+
self.theclass.strptime(test_time, "%H:%M:%S")
3794+
)
3795+
37973796

37983797
class TestSubclassDateTime(TestDateTime):
37993798
theclass = SubclassDatetime

0 commit comments

Comments
 (0)