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

Method test_fromisoformat_fails

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

Source from the content-addressed store, hash-verified

2084 self.assertIsInstance(dt_rt, DateSubclass)
2085
2086 def test_fromisoformat_fails(self):
2087 # Test that fromisoformat() fails on invalid values
2088 bad_strs = [
2089 '', # Empty string
2090 '\ud800', # bpo-34454: Surrogate code point
2091 '009-03-04', # Not 10 characters
2092 '123456789', # Not a date
2093 '200a-12-04', # Invalid character in year
2094 '2009-1a-04', # Invalid character in month
2095 '2009-12-0a', # Invalid character in day
2096 '2009-01-32', # Invalid day
2097 '2009-02-29', # Invalid leap day
2098 '2019-W53-1', # No week 53 in 2019
2099 '2020-W54-1', # No week 54
2100 '0000-W25-1', # Invalid year
2101 '10000-W25-1', # Invalid year
2102 '2020-W25-0', # Invalid day-of-week
2103 '2020-W25-8', # Invalid day-of-week
2104 '٢025-03-09' # Unicode characters
2105 '2009\ud80002\ud80028', # Separators are surrogate codepoints
2106 ]
2107
2108 for bad_str in bad_strs:
2109 with self.assertRaises(ValueError):
2110 self.theclass.fromisoformat(bad_str)
2111
2112 def test_fromisoformat_fails_typeerror(self):
2113 # Test that fromisoformat fails when passed the wrong type

Callers

nothing calls this directly

Calls 2

assertRaisesMethod · 0.45
fromisoformatMethod · 0.45

Tested by

no test coverage detected