Coverage for tests/serializers/pydantic/test_serializer.py: 100%
7 statements
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-13 05:19 +0000
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-13 05:19 +0000
1from fast_depends import Provider, inject 1abcdefghijklmno
2from fast_depends.pydantic import PydanticSerializer 1abcdefghijklmno
5def test_non_class_response_type() -> None: 1abcdefghijklmno
6 """`issubclass()` raises for non-class annotations such as unions.
8 The serializer has to fall back to a `TypeAdapter` instead of treating the
9 annotation as a model.
10 """
12 @inject( 1abcdefghijklmno
13 serializer_cls=PydanticSerializer(),
14 dependency_provider=Provider(),
15 cast_result=True,
16 )
17 def func(a: int) -> int | None: 1abcdefghijklmno
18 return a 1abcdefghijklmno
20 assert func("1") == 1 1abcdefghijklmno