-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add backward compatibility with Pydantic V1 base models
- Loading branch information
Showing
8 changed files
with
1,173 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
""" | ||
Specific confest.py file for testing behavior with Pydantic V1. | ||
The fixtures below override the confest.py's fixtures for this module only. | ||
""" | ||
|
||
from typing import List, Optional, Type | ||
|
||
import pytest | ||
|
||
from pydantic.v1 import BaseModel | ||
|
||
|
||
@pytest.fixture | ||
def query_model() -> Type[BaseModel]: | ||
class Query(BaseModel): | ||
limit: int = 2 | ||
min_views: Optional[int] = None | ||
|
||
return Query | ||
|
||
|
||
@pytest.fixture | ||
def body_model() -> Type[BaseModel]: | ||
class Body(BaseModel): | ||
search_term: str | ||
exclude: Optional[str] = None | ||
|
||
return Body | ||
|
||
|
||
@pytest.fixture | ||
def form_model() -> Type[BaseModel]: | ||
class Form(BaseModel): | ||
search_term: str | ||
exclude: Optional[str] = None | ||
|
||
return Form | ||
|
||
|
||
@pytest.fixture | ||
def post_model() -> Type[BaseModel]: | ||
class Post(BaseModel): | ||
title: str | ||
text: str | ||
views: int | ||
|
||
return Post | ||
|
||
|
||
@pytest.fixture | ||
def response_model(post_model: BaseModel) -> Type[BaseModel]: | ||
class Response(BaseModel): | ||
results: List[post_model] | ||
count: int | ||
|
||
return Response |
Empty file.
Oops, something went wrong.