File: test_predicates.py

package info (click to toggle)
python-polyfactory 3.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,148 kB
  • sloc: python: 11,529; makefile: 102; sh: 34
file content (18 lines) | stat: -rw-r--r-- 435 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from typing import Literal, Union

import pytest

from polyfactory.utils.predicates import is_literal


@pytest.mark.parametrize(
    "annotation,expected",
    [
        (Literal[1, 2, 3], True),
        (Union[int, str], False),
        (Union[Literal[1], Literal[2]], False),  # noqa: PYI030
        (int, False),
    ],
)
def test_is_literal(annotation: type, expected: bool) -> None:
    assert is_literal(annotation) is expected