"""Handler tests.""" import math from string import printable from hypothesis import given, strategies as st from video.constants import field_types from video.utils import typer anything_strategy = st.recursive( st.none() | st.booleans() | st.floats() | st.integers() | st.text(printable), lambda children: ( st.none() | st.booleans() | st.floats() | st.integers() | st.text(printable) | st.lists(children, min_size=1) | st.dictionaries(st.text(printable), children, min_size=1) ), ) @given( value=anything_strategy.filter( lambda x: not isinstance(x, float) or not math.isnan(x) ), ) def test_typer(value: object) -> None: """Test typer.""" original_value_data_type = typer.typer(value) unstringified_value = typer.unstringify(typer.stringify(value)) assert original_value_data_type in field_types.FIELD_TYPES assert original_value_data_type == typer.typer(unstringified_value)