Path: blob/main/py-polars/tests/unit/testing/parametric/strategies/test_data.py
8424 views
from __future__ import annotations12from hypothesis import given34import polars as pl5from polars.testing.parametric.strategies.data import categories, data678@given(cat=categories(3))9def test_categories(cat: str) -> None:10assert cat in ("c0", "c1", "c2")111213@given(cat=data(pl.Categorical, n_categories=3))14def test_data_kwargs(cat: str) -> None:15assert cat in ("c0", "c1", "c2")161718@given(categories=data(pl.List(pl.Categorical), n_categories=3))19def test_data_nested_kwargs(categories: list[str]) -> None:20assert all(c in ("c0", "c1", "c2") for c in categories)212223@given(cat=data(pl.Enum))24def test_data_enum(cat: str) -> None:25assert cat in ("c0", "c1", "c2")262728@given(cat=data(pl.Enum(["hello", "world"])))29def test_data_enum_instantiated(cat: str) -> None:30assert cat in ("hello", "world")313233@given(struct=data(pl.Struct({"a": pl.Int8, "b": pl.String})))34def test_data_struct(struct: dict[str, int | str]) -> None:35assert isinstance(struct["a"], int)36assert isinstance(struct["b"], str)373839