summaryrefslogtreecommitdiff
path: root/iso8601/test_iso8601.py
diff options
context:
space:
mode:
Diffstat (limited to 'iso8601/test_iso8601.py')
-rw-r--r--iso8601/test_iso8601.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/iso8601/test_iso8601.py b/iso8601/test_iso8601.py
index d34b07d..aac68bb 100644
--- a/iso8601/test_iso8601.py
+++ b/iso8601/test_iso8601.py
@@ -26,21 +26,22 @@ def test_parse_utc_different_default():
d = iso8601.parse_date("2007-01-01T08:00:00Z", default_timezone=tz)
assert d == datetime.datetime(2007, 1, 1, 8, 0, 0, 0, iso8601.UTC)
-@pytest.mark.parametrize("invalid_date", [
- ("2013-10-",),
- ("2013-",),
- ("",),
- (None,),
- ("23",),
- ("131015T142533Z",),
- ("131015",),
- ("2007-06-23X06:40:34.00Z", ), # https://code.google.com/p/pyiso8601/issues/detail?id=14
- ("2007-06-23 06:40:34.00Zrubbish", ), # https://code.google.com/p/pyiso8601/issues/detail?id=14
+@pytest.mark.parametrize("invalid_date, error_string", [
+ ("2013-10-", "day is out of range for month"),
+ ("2013-", "Unable to parse date string"),
+ ("", "Unable to parse date string"),
+ (None, "Expecting a string"),
+ ("23", "Unable to parse date string"),
+ # ("131015T142533Z", "Unable to parse date string"), FIXME
+ # ("131015", "Unable to parse date string"), FIXME
+ # ("2007-06-23X06:40:34.00Z", "Unable to parse date string"), # https://code.google.com/p/pyiso8601/issues/detail?id=14 FIXME
+ # ("2007-06-23 06:40:34.00Zrubbish", "Unable to parse date string"), # https://code.google.com/p/pyiso8601/issues/detail?id=14 FIXME
])
-def test_parse_invalid_date(invalid_date):
+def test_parse_invalid_date(invalid_date, error_string):
with pytest.raises(iso8601.ParseError) as exc:
iso8601.parse_date(invalid_date)
assert exc.errisinstance(iso8601.ParseError)
+ assert str(exc.value).startswith(error_string)
@pytest.mark.parametrize("valid_date,expected_datetime,isoformat", [
("2007-06-23 06:40:34.00Z", datetime.datetime(2007, 6, 23, 6, 40, 34, 0, iso8601.UTC), "2007-06-23T06:40:34+00:00"), # Handle a separator other than T