summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjulien <julien@danjou.info>2014-02-18 15:36:03 +0100
committerjulien <julien@danjou.info>2014-02-18 15:36:03 +0100
commitc310ac5c62a10171d3502358368a91a52b014f38 (patch)
tree0c9d192c2d4d246789128ce456411bd018834392
parent979fd443a0038d29f0223b2fdd22d77b09c8e3dd (diff)
downloadpyiso8601-c310ac5c62a10171d3502358368a91a52b014f38.tar.gz
test: fix test cases on error
The syntax used on pytest.mark.parametrize was wrong and therefore the argument "invalid_date" was passed as a tuple: whatever the value in that tuple was, the parsing function was always failing because the data type was wrong.
-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