found = format_regex.match(data_string)
if not found:
raise ValueError("time data did not match format")
+ if len(data_string) != found.end():
+ raise ValueError("unconverted data remains: %s" %
+ data_string[found.end():])
year = 1900
month = day = 1
hour = minute = second = 0
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)