Skip to content

Commit

Permalink
Merge pull request #2 from der-michik/master
Browse files Browse the repository at this point in the history
Fix exception when comparing sets to other objects
  • Loading branch information
runfalk committed Jun 27, 2016
2 parents 9a781cf + f3c31b2 commit 7d33d14
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ Version 0.2.0
Released on 22nd December, 2015

- Added :meth:`~spans.settypes.rangeset.__len__` to range sets
(`Michael Krate <https://github.com/der-michik>`_)
(`Michael Krahe <https://github.com/der-michik>`_)
- Added :meth:`~spans.settypes.rangeset.contains` to range sets
(`Michael Krate <https://github.com/der-michik>`_)
(`Michael Krahe <https://github.com/der-michik>`_)
- Added `Sphinx <http://sphinx-doc.org/>`_ style doc strings to all methods
- Added proper Sphinx documentation
- Added unit tests for uncovered parts, mostly error checking
Expand Down
4 changes: 4 additions & 0 deletions spans/settypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,13 @@ def __iter__(self):
return iter(self._list)

def __eq__(self, other):
if not isinstance(other, self.__class__):
return NotImplemented
return self._list == other._list

def __lt__(self, other):
if not isinstance(other, self.__class__):
return NotImplemented
return self._list < other._list

def __len__(self):
Expand Down
4 changes: 4 additions & 0 deletions spans/tests/test_settypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ def test_equal(self):
intrangeset([range_a, range_b]) == intrangeset([range_a, range_b]))
self.assertFalse(
intrangeset([range_a, range_b]) == intrangeset([range_a]))
self.assertFalse(
intrangeset([range_a]) == "foo")

def test_less_than(self):
range_a = intrange(1, 5)
Expand All @@ -134,6 +136,8 @@ def test_less_than(self):
intrangeset([range_a, range_b]) < intrangeset([range_b]))
self.assertFalse(
intrangeset([range_a, range_b]) <= intrangeset([range_a]))
self.assertFalse(
intrangeset([range_a]) == "foo")

def test_greater_than(self):
range_a = intrange(1, 5)
Expand Down

0 comments on commit 7d33d14

Please sign in to comment.