Skip to content

Commit

Permalink
add pydantic computed field to tests #1354
Browse files Browse the repository at this point in the history
  • Loading branch information
tfranzel committed Dec 18, 2024
1 parent 9bf8e92 commit 381e9ea
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
@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 381e9ea

Please sign in to comment.