Skip to content

Commit

Permalink
Merge pull request #1355 from tfranzel/pydantic_computed
Browse files Browse the repository at this point in the history
add pydantic computed field to tests #1354
  • Loading branch information
tfranzel authored Dec 19, 2024
2 parents 9bf8e92 + d167260 commit 5734744
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/contrib/test_pydantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -18,6 +18,9 @@ class BaseModel: # type: ignore
def dataclass(f):
return f

def computed_field(f):
return f


@dataclass
class C:
Expand All @@ -34,6 +37,11 @@ class A(BaseModel):
b: B
d: Decimal

@computed_field # type: ignore[misc]
@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')
Expand Down
5 changes: 5 additions & 0 deletions tests/contrib/test_pydantic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 5734744

Please sign in to comment.