From 381e9ea0abe280d3698185ee5830a17b72fe4daf Mon Sep 17 00:00:00 2001 From: "T. Franzel" Date: Wed, 18 Dec 2024 14:55:33 +0700 Subject: [PATCH] add pydantic computed field to tests #1354 --- tests/contrib/test_pydantic.py | 10 +++++++++- tests/contrib/test_pydantic.yml | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/contrib/test_pydantic.py b/tests/contrib/test_pydantic.py index 49ade8cc..63619a4b 100644 --- a/tests/contrib/test_pydantic.py +++ b/tests/contrib/test_pydantic.py @@ -9,7 +9,7 @@ from tests import assert_schema, generate_schema try: - from pydantic import BaseModel + from pydantic import BaseModel, computed_field from pydantic.dataclasses import dataclass except ImportError: class BaseModel: # type: ignore @@ -18,6 +18,9 @@ class BaseModel: # type: ignore def dataclass(f): return f + def computed_field(f): + return f + @dataclass class C: @@ -34,6 +37,11 @@ class A(BaseModel): b: B d: Decimal + @computed_field + @property + def x(self) -> int: + return 42 + @pytest.mark.contrib('pydantic') @pytest.mark.skipif(sys.version_info < (3, 7), reason='python 3.7+ is required by package') diff --git a/tests/contrib/test_pydantic.yml b/tests/contrib/test_pydantic.yml index 0680074a..31647d9e 100644 --- a/tests/contrib/test_pydantic.yml +++ b/tests/contrib/test_pydantic.yml @@ -43,10 +43,15 @@ components: d: title: D type: string + x: + readOnly: true + title: X + type: integer required: - id - b - d + - x title: A type: object B: