Raise a ValueError when there is data that was not covered in the format string. Done to match behavior of pre-existing C-based strptime implementations.

This commit is contained in:
Brett Cannon 2003-04-28 21:30:13 +00:00
parent a390c6e194
commit 2b6dfec1cc
2 changed files with 7 additions and 0 deletions

View file

@ -227,6 +227,10 @@ class StrptimeTests(unittest.TestCase):
self.assertRaises(ValueError, _strptime.strptime, data_string="%d",
format="%A")
def test_unconverteddata(self):
# Check ValueError is raised when there is unconverted data
self.assertRaises(ValueError, _strptime.strptime, "10 12", "%m")
def helper(self, directive, position):
"""Helper fxn in testing."""
strf_output = time.strftime("%" + directive, self.time_tuple)