Skip to content

Commit

Permalink
Add test case for exceptions on invalid enum value
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobiasd committed Aug 29, 2020
1 parent 230c291 commit f225a3a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions undictify/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,12 @@ def test_int_enum(self) -> None:
obj = WithIntEnum(**json.loads(object_repr))
self.assertEqual(SomeIntEnum.BAR, obj.int_enum)

def test_int_enum_invalid(self) -> None:
"""Invalid JSON string."""
object_repr = '''{"int_enum": 9999}'''
with self.assertRaises(TypeError):
WithIntEnum(**json.loads(object_repr))

def test_str_enum(self) -> None:
"""Valid JSON string."""
object_repr = '''{"str_enum": "NOTEXACTLYBAR"}'''
Expand Down

0 comments on commit f225a3a

Please sign in to comment.