MCPcopy Index your code
hub / github.com/python/cpython / test_fromisoformat_date_examples

Method test_fromisoformat_date_examples

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

Source from the content-addressed store, hash-verified

2039 self.assertEqual(dt, dt_rt)
2040
2041 def test_fromisoformat_date_examples(self):
2042 examples = [
2043 ('00010101', self.theclass(1, 1, 1)),
2044 ('20000101', self.theclass(2000, 1, 1)),
2045 ('20250102', self.theclass(2025, 1, 2)),
2046 ('99991231', self.theclass(9999, 12, 31)),
2047 ('0001-01-01', self.theclass(1, 1, 1)),
2048 ('2000-01-01', self.theclass(2000, 1, 1)),
2049 ('2025-01-02', self.theclass(2025, 1, 2)),
2050 ('9999-12-31', self.theclass(9999, 12, 31)),
2051 ('2025W01', self.theclass(2024, 12, 30)),
2052 ('2025-W01', self.theclass(2024, 12, 30)),
2053 ('2025W014', self.theclass(2025, 1, 2)),
2054 ('2025-W01-4', self.theclass(2025, 1, 2)),
2055 ('2026W01', self.theclass(2025, 12, 29)),
2056 ('2026-W01', self.theclass(2025, 12, 29)),
2057 ('2026W013', self.theclass(2025, 12, 31)),
2058 ('2026-W01-3', self.theclass(2025, 12, 31)),
2059 ('2022W52', self.theclass(2022, 12, 26)),
2060 ('2022-W52', self.theclass(2022, 12, 26)),
2061 ('2022W527', self.theclass(2023, 1, 1)),
2062 ('2022-W52-7', self.theclass(2023, 1, 1)),
2063 ('2015W534', self.theclass(2015, 12, 31)), # Has week 53
2064 ('2015-W53-4', self.theclass(2015, 12, 31)), # Has week 53
2065 ('2015-W53-5', self.theclass(2016, 1, 1)),
2066 ('2020W531', self.theclass(2020, 12, 28)), # Leap year
2067 ('2020-W53-1', self.theclass(2020, 12, 28)), # Leap year
2068 ('2020-W53-6', self.theclass(2021, 1, 2)),
2069 ]
2070
2071 for input_str, expected in examples:
2072 with self.subTest(input_str=input_str):
2073 actual = self.theclass.fromisoformat(input_str)
2074 self.assertEqual(actual, expected)
2075
2076 def test_fromisoformat_subclass(self):
2077 class DateSubclass(self.theclass):

Callers

nothing calls this directly

Calls 3

subTestMethod · 0.45
fromisoformatMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected