diff --git a/tests/integration/test_serializer.py b/tests/integration/test_serializer.py index 12cbc49..e284091 100644 --- a/tests/integration/test_serializer.py +++ b/tests/integration/test_serializer.py @@ -8,10 +8,10 @@ @pytest.mark.parametrize("obj", [FooModel(num=42, s="spam", bar=FooModel.Bar(str2int={"eggs": 59}))]) -def test_pydantic_dump_json_load_ok( - pydantic_serializer: PydanticSerializer, +def test_pydantic_dump_json_load_ok[T: BaseModel]( + pydantic_serializer: PydanticSerializer[T], json_serializer: JSONSerializer, - message: Message[object], + message: Message[T], obj: BaseModel, ) -> None: loaded = json_serializer.load_message(pydantic_serializer.dump_message(message)) @@ -20,10 +20,10 @@ def test_pydantic_dump_json_load_ok( @pytest.fixture -def pydantic_serializer(obj: BaseModel) -> PydanticSerializer: +def pydantic_serializer[T: BaseModel](obj: T) -> PydanticSerializer[T]: return PydanticSerializer(type(obj)) @pytest.fixture -def message(obj: object, stub_routing_key: str) -> Message[object]: +def message[T: BaseModel](obj: T, stub_routing_key: str) -> Message[T]: return AppMessage(body=obj, routing_key=stub_routing_key) diff --git a/tests/unit/serializer/test_pydantic.py b/tests/unit/serializer/test_pydantic.py index a7086de..eedb97b 100644 --- a/tests/unit/serializer/test_pydantic.py +++ b/tests/unit/serializer/test_pydantic.py @@ -7,17 +7,17 @@ @pytest.mark.parametrize("obj", [FooModel(num=42, s="spam", bar=FooModel.Bar(str2int={"eggs": 59}))]) -def test_dump_load_ok(serializer: PydanticSerializer, message: Message[object]) -> None: +def test_dump_load_ok[T: BaseModel](serializer: PydanticSerializer[T], message: Message[T]) -> None: loaded = serializer.load_message(serializer.dump_message(message)) assert loaded.body == message.body @pytest.fixture -def serializer(obj: BaseModel) -> PydanticSerializer: +def serializer[T: BaseModel](obj: T) -> PydanticSerializer[T]: return PydanticSerializer(type(obj)) @pytest.fixture -def message(obj: object, stub_routing_key: str) -> Message[object]: +def message[T: BaseModel](obj: T, stub_routing_key: str) -> Message[T]: return AppMessage(body=obj, routing_key=stub_routing_key)