-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration test for custom types
- Loading branch information
JensHeinrich
authored and
JensHeinrich
committed
Aug 11, 2023
1 parent
2c050a7
commit dfaae3e
Showing
2 changed files
with
61 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from ..case import Case | ||
from ..file import File | ||
|
||
cases = [ | ||
Case( | ||
name="Mark __get_validators__", | ||
source=File( | ||
"mark_get_validators.py", | ||
content=[ | ||
"class SomeThing:", | ||
" @classmethod", | ||
" def __get_validators__(cls):", | ||
" yield from []", | ||
" return", | ||
], | ||
), | ||
expected=File( | ||
"mark_get_validators.py", | ||
content=[ | ||
"class SomeThing:", | ||
" @classmethod", | ||
" # TODO[pydantic]: We couldn't refactor `__get_validators__`, please create the `__get_pydantic_core_schema__` manually.", # noqa: E501 | ||
" # Check https://docs.pydantic.dev/latest/migration/#defining-custom-types for more information.", | ||
" def __get_validators__(cls):", | ||
" yield from []", | ||
" return", | ||
], | ||
), | ||
), | ||
Case( | ||
name="Mark __modify_schema__", | ||
source=File( | ||
"mark_modify_schema.py", | ||
content=[ | ||
"class SomeThing:", | ||
" @classmethod", | ||
" def __modify_schema__(", | ||
" cls, field_schema: Dict[str, Any], field: Optional[ModelField]", | ||
" ):", | ||
" if field:", | ||
" field_schema['example'] = \"Weird example\"", | ||
], | ||
), | ||
expected=File( | ||
"mark_modify_schema.py", | ||
content=[ | ||
"class SomeThing:", | ||
" @classmethod", | ||
" # TODO[pydantic]: We couldn't refactor `__modify_schema__`, please create the `__get_pydantic_json_schema__` manually.", # noqa: E501 | ||
" # Check https://docs.pydantic.dev/latest/migration/#defining-custom-types for more information.", | ||
" def __modify_schema__(", | ||
" cls, field_schema: Dict[str, Any], field: Optional[ModelField]", | ||
" ):", | ||
" if field:", | ||
" field_schema['example'] = \"Weird example\"", | ||
], | ||
), | ||
), | ||
] |