From 418113dba98787658eef56c9eb8750a7fab36ec4 Mon Sep 17 00:00:00 2001 From: Jace Browning Date: Fri, 29 Jan 2021 18:51:23 -0500 Subject: [PATCH] Add failing tests for optional enum bug --- datafiles/tests/test_converters.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/datafiles/tests/test_converters.py b/datafiles/tests/test_converters.py index 86196111..0e512e39 100644 --- a/datafiles/tests/test_converters.py +++ b/datafiles/tests/test_converters.py @@ -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): @@ -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):