Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pydantic computed field to tests #1354 #1355

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
def dataclass(f):
return f

def computed_field(f):
return f


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

@computed_field # type: ignore[misc]
@property
def x(self) -> int:
return 42

Check warning on line 43 in tests/contrib/test_pydantic.py

View check run for this annotation

Codecov / codecov/patch

tests/contrib/test_pydantic.py#L43

Added line #L43 was not covered by tests


@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
Loading