File: test_parsers.py

package info (click to toggle)
dataclass-wizard 0.37.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 2,924 kB
  • sloc: python: 17,189; makefile: 126; javascript: 23
file content (17 lines) | stat: -rw-r--r-- 561 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import pytest

from typing import Literal

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