diff --git a/tests/unit/test_parsers.py b/tests/unit/test_parsers.py new file mode 100644 index 00000000..59dbb6d1 --- /dev/null +++ b/tests/unit/test_parsers.py @@ -0,0 +1,17 @@ +from typing import Literal + +import pytest + +from dataclass_wizard.parsers import LiteralParser + + +class TestLiteralParser: + @pytest.fixture + def literal_parser(self) -> LiteralParser: + return LiteralParser(cls=object, base_type=Literal["foo"], extras={}) + + def test_literal_parser_dunder_contains_succeeds_if_item_in_keys_of_base_type(self, literal_parser): + assert "foo" in literal_parser + + def test_literal_parser_dunder_contains_fails_if_item_not_in_keys_of_base_type(self, literal_parser): + assert "bar" not in literal_parser