Skip to content

Commit

Permalink
Merge pull request arrow-py#253 from itsmeolivia/fix-241
Browse files Browse the repository at this point in the history
Raise TypeError when adding/subtracting non-dates Thanks @itsmeolivia
  • Loading branch information
andrewelkins committed Aug 7, 2015
2 parents ce06625 + e400261 commit f9889fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions arrow/arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ def __add__(self, other):
if isinstance(other, (timedelta, relativedelta)):
return self.fromdatetime(self._datetime + other, self._datetime.tzinfo)

raise NotImplementedError()
raise TypeError()

def __radd__(self, other):
return self.__add__(other)
Expand All @@ -685,7 +685,7 @@ def __sub__(self, other):
elif isinstance(other, Arrow):
return self._datetime - other._datetime

raise NotImplementedError()
raise TypeError()

def __rsub__(self, other):
return self.__sub__(other)
Expand Down
5 changes: 2 additions & 3 deletions tests/arrow_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def test_add_timedelta(self):

def test_add_other(self):

with assertRaises(NotImplementedError):
with assertRaises(TypeError):
self.arrow.__add__(1)

def test_radd(self):
Expand Down Expand Up @@ -290,7 +290,7 @@ def test_sub_arrow(self):

def test_sub_other(self):

with assertRaises(NotImplementedError):
with assertRaises(TypeError):
self.arrow.__sub__(object())

def test_rsub(self):
Expand Down Expand Up @@ -1121,4 +1121,3 @@ def test_get_iteration_params(self):

with assertRaises(Exception):
arrow.Arrow._get_iteration_params(None, None)

0 comments on commit f9889fb

Please sign in to comment.