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

Method test_fromisoformat

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

Source from the content-addressed store, hash-verified

2019 self.assertIn(f"day 32 must be in range 1..31 for month 1 in year 2009", str(msg.exception))
2020
2021 def test_fromisoformat(self):
2022 # Test that isoformat() is reversible
2023 base_dates = [
2024 (1, 1, 1),
2025 (1000, 2, 14),
2026 (1900, 1, 1),
2027 (2000, 2, 29),
2028 (2004, 11, 12),
2029 (2004, 4, 3),
2030 (2017, 5, 30)
2031 ]
2032
2033 for dt_tuple in base_dates:
2034 dt = self.theclass(*dt_tuple)
2035 dt_str = dt.isoformat()
2036 with self.subTest(dt_str=dt_str):
2037 dt_rt = self.theclass.fromisoformat(dt.isoformat())
2038
2039 self.assertEqual(dt, dt_rt)
2040
2041 def test_fromisoformat_date_examples(self):
2042 examples = [

Callers

nothing calls this directly

Calls 4

isoformatMethod · 0.45
subTestMethod · 0.45
fromisoformatMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected