From 33d30e3e304b85769555508783809184f56a75d0 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 18 Nov 2015 13:08:18 +0100 Subject: Fix FixedOffset comparison Fixes #19 --- iso8601/iso8601.py | 4 +--- iso8601/test_iso8601.py | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/iso8601/iso8601.py b/iso8601/iso8601.py index c8284d4..59273e1 100644 --- a/iso8601/iso8601.py +++ b/iso8601/iso8601.py @@ -115,9 +115,7 @@ else: and (other.__name == self.__name) ) - if isinstance(other, tzinfo): - return other == self - return False + return NotImplemented def __getinitargs__(self): return (self.__offset_hours, self.__offset_minutes, self.__name) diff --git a/iso8601/test_iso8601.py b/iso8601/test_iso8601.py index bc5e763..0d01ffb 100644 --- a/iso8601/test_iso8601.py +++ b/iso8601/test_iso8601.py @@ -12,6 +12,10 @@ from iso8601 import iso8601 def test_iso8601_regex(): assert iso8601.ISO8601_REGEX.match("2006-10-11T00:14:33Z") +def test_fixedoffset_eq(): + # See https://bitbucket.org/micktwomey/pyiso8601/issues/19 + datetime.tzinfo() == iso8601.FixedOffset(2, 0, '+2:00') + def test_parse_no_timezone_different_default(): tz = iso8601.FixedOffset(2, 0, "test offset") d = iso8601.parse_date("2007-01-01T08:00:00", default_timezone=tz) -- cgit v1.2.1