Skip to content

Commit

Permalink
Add failing tests for optional enum bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Jan 29, 2021
1 parent 80887f3 commit 418113d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions datafiles/tests/test_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ def when_enum(expect):
with expect.raises(ValueError):
convert(42)

@pytest.mark.xfail(
reason='https://github.com/jacebrowning/datafiles/issues/194'
)
def when_optional_enum(expect):
convert = converters.map_type(Optional[Color]).to_python_value
expect(convert(None)).is_(None)

def when_invalid(expect):
message = "invalid literal for int() with base 10: 'a'"
with expect.raises(ValueError, message):
Expand Down Expand Up @@ -269,6 +276,13 @@ def when_enum(expect):
convert = converters.map_type(Color).to_preserialization_data
expect(convert(Color.RED)) == 1

@pytest.mark.xfail(
reason='https://github.com/jacebrowning/datafiles/issues/194'
)
def when_optional_enum(expect):
convert = converters.map_type(Optional[Color]).to_preserialization_data
expect(convert(None)).is_(None)

def when_invalid(expect):
message = "invalid literal for int() with base 10: 'a'"
with expect.raises(ValueError, message):
Expand Down

0 comments on commit 418113d

Please sign in to comment.