MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_strptime_single_digit

Method test_strptime_single_digit

Lib/test/datetimetester.py:1176–1202  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1174 self.assertIs(type(got), date)
1175
1176 def test_strptime_single_digit(self):
1177 # bpo-34903: Check that single digit dates are allowed.
1178 strptime = date.strptime
1179 with self.assertRaises(ValueError):
1180 # %y does require two digits.
1181 newdate = strptime('01/02/3', '%d/%m/%y')
1182
1183 d1 = date(2003, 2, 1)
1184 d2 = date(2003, 1, 2)
1185 d3 = date(2003, 1, 25)
1186 inputs = [
1187 ('%d', '1/02/03', '%d/%m/%y', d1),
1188 ('%m', '01/2/03', '%d/%m/%y', d1),
1189 ('%j', '2/03', '%j/%y', d2),
1190 ('%w', '6/04/03', '%w/%U/%y', d1),
1191 # %u requires a single digit.
1192 ('%W', '6/4/2003', '%u/%W/%Y', d1),
1193 ('%V', '6/4/2003', '%u/%V/%G', d3),
1194 ]
1195 for reason, string, format, target in inputs:
1196 reason = 'test single digit ' + reason
1197 with self.subTest(reason=reason,
1198 string=string,
1199 format=format,
1200 target=target):
1201 newdate = strptime(string, format)
1202 self.assertEqual(newdate, target, msg=reason)
1203
1204 @warnings_helper.ignore_warnings(category=DeprecationWarning)
1205 def test_strptime_leap_year(self):

Callers

nothing calls this directly

Calls 5

dateClass · 0.90
strptimeFunction · 0.85
subTestMethod · 0.80
assertRaisesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected