Skip to content

Commit

Permalink
Add additional tests for converting empty values to an Enum
Browse files Browse the repository at this point in the history
Passing an empty string or None has to fail.
  • Loading branch information
bjoernricks committed May 29, 2024
1 parent c01039b commit 4f92344
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ def test_invalid(self) -> None:
):
SomeEnum("BAZ")

with self.assertRaisesRegex(
ValueError,
"^'' is not a valid SomeEnum$",
):
SomeEnum("")

with self.assertRaisesRegex(
ValueError,
"^None is not a valid SomeEnum$",
):
SomeEnum(None)

def test_from_string(self) -> None:
enum = SomeEnum.from_string("FOO")
self.assertEqual(enum, SomeEnum.FOO)
Expand Down

0 comments on commit 4f92344

Please sign in to comment.