Skip to content

Commit

Permalink
Catch TypeError in python-dateutil parser
Browse files Browse the repository at this point in the history
Add test to check this behavior
  • Loading branch information
Vladimir Bolshakov authored and Deepwalker committed Nov 24, 2017
1 parent abd2f03 commit 4e6e3f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions tests/test_contrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ class TestDateTime(unittest.TestCase):
def test_datetime(self):
check = DateTime()
assert check('2017-09-01 23:59') == datetime.datetime(2017, 9, 1, 23, 59)

def test_datetime_in_or(self):
nullable_datetime = t.Or(DateTime, t.Null)
assert nullable_datetime.check(None) is None
4 changes: 2 additions & 2 deletions trafaret/contrib/rfc_3339.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ def check_and_return(self, value):
return value
try:
return parse(value)
except ValueError as e:
self._failure(e.message)
except (ValueError, TypeError) as e:
self._failure(str(e))

0 comments on commit 4e6e3f4

Please sign in to comment.