From 292b24a47d8e417a81bc105eec0dcd89dda1f716 Mon Sep 17 00:00:00 2001 From: Michael Twomey Date: Fri, 18 Oct 2013 17:39:16 +0100 Subject: Handle negative timezone offsets correctly I had dropped the negative minutes in a braino and had incorrectly updated tests to match. I've added a isoformat field to the tests, so I can correctly assert they formatted date looks right. Thanks to Jonathan Lange for reporting this and a patch. Fixes #8 --- iso8601/test_iso8601.py | 51 +++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 23 deletions(-) (limited to 'iso8601/test_iso8601.py') diff --git a/iso8601/test_iso8601.py b/iso8601/test_iso8601.py index 30d6a1d..5ec4e69 100644 --- a/iso8601/test_iso8601.py +++ b/iso8601/test_iso8601.py @@ -42,30 +42,33 @@ def test_parse_invalid_date(invalid_date): iso8601.parse_date(invalid_date) assert exc.errisinstance(iso8601.ParseError) -@pytest.mark.parametrize("valid_date,expected_datetime", [ - ("2007-06-23 06:40:34.00Z", datetime.datetime(2007, 6, 23, 6, 40, 34, 0, iso8601.UTC)), # Handle a separator other than T - ("1997-07-16T19:20+01:00", datetime.datetime(1997, 7, 16, 19, 20, 0, 0, iso8601.FixedOffset(1, 0, "+01:00"))), # Parse with no seconds - ("2007-01-01T08:00:00", datetime.datetime(2007, 1, 1, 8, 0, 0, 0, iso8601.UTC)), # Handle timezone-less dates. Assumes UTC. http://code.google.com/p/pyiso8601/issues/detail?id=4 - ("2006-10-20T15:34:56.123+02:30", datetime.datetime(2006, 10, 20, 15, 34, 56, 123000, iso8601.FixedOffset(2, 30, "+02:30"))), - ("2006-10-20T15:34:56Z", datetime.datetime(2006, 10, 20, 15, 34, 56, 0, iso8601.UTC)), - ("2007-5-7T11:43:55.328Z'", datetime.datetime(2007, 5, 7, 11, 43, 55, 328000, iso8601.UTC)), # http://code.google.com/p/pyiso8601/issues/detail?id=6 - ("2006-10-20T15:34:56.123Z", datetime.datetime(2006, 10, 20, 15, 34, 56, 123000, iso8601.UTC)), - ("2013-10-15T18:30Z", datetime.datetime(2013, 10, 15, 18, 30, 0, 0, iso8601.UTC)), - ("2013-10-15T22:30+04", datetime.datetime(2013, 10, 15, 22, 30, 0, 0, iso8601.FixedOffset(4, 0, "+04:00"))), #