Skip to content

Commit

Permalink
Merge pull request #36 from mbourqui/fix/#35
Browse files Browse the repository at this point in the history
Fix #35
  • Loading branch information
mbourqui authored Aug 9, 2017
2 parents 81a8211 + ee9b092 commit 642628b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion echoices/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def __eq__(self, other):
return self.value == other.value
try:
return self.value == self.coerce(other)
except TypeError:
except (TypeError, ValueError):
return False

def __ge__(self, other):
Expand Down
4 changes: 3 additions & 1 deletion echoices/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ def test_get(self):

def test_coerce(self):
self.assertEquals(ETestIntChoices.coerce('1'), 1)
# TODO: expand
self.assertRaises(TypeError, ETestIntChoices.coerce, None)
self.assertRaises(ValueError, ETestIntChoices.coerce, '')

def test_call(self):
self.assertIs(ETestCharChoices.FIELD1('name'), ETestCharChoices.FIELD1.name)
Expand Down Expand Up @@ -233,6 +234,7 @@ def test_orderable(self):
self.assertFalse(ETestIntOrderedChoices.FIELD2 == 20)
self.assertFalse(ETestIntOrderedChoices.FIELD2 == '20')
self.assertFalse(ETestIntOrderedChoices.FIELD2 == None)
self.assertFalse(ETestIntOrderedChoices.FIELD2 == '')
self.assertTrue(ETestStrOrderedChoices.FIELD3 < ETestStrOrderedChoices.FIELD1)
self.assertTrue(ETestIntOrderedChoices.FIELD3 < ETestIntOrderedChoices.FIELD1)
self.assertTrue(ETestIntOrderedChoices.FIELD3 < 30)
Expand Down

0 comments on commit 642628b

Please sign in to comment.