From b05e1da66b399e8fcaaada60dc9b44b8bb94a957 Mon Sep 17 00:00:00 2001 From: Mike Weltevrede <46759318+mikeweltevrede@users.noreply.github.com> Date: Wed, 21 Feb 2024 15:17:52 +0100 Subject: [PATCH] Add tests --- tests/unit/test_parsers.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tests/unit/test_parsers.py 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