✨ Add support for Pydantic v2 (while keeping support for v1 if v2 is not available), including initial work by AntonDeMeester (#722)
Co-authored-by: Mohamed Farahat <farahats9@yahoo.com> Co-authored-by: Stefan Borer <stefan.borer@gmail.com> Co-authored-by: Peter Landry <peter.landry@gmail.com> Co-authored-by: Anton De Meester <antondemeester+github@gmail.com>
This commit is contained in:
committed by
GitHub
parent
5b733b348d
commit
fa2f178b8a
30
tests/test_deprecations.py
Normal file
30
tests/test_deprecations.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import pytest
|
||||
from sqlmodel import SQLModel
|
||||
|
||||
|
||||
class Item(SQLModel):
|
||||
name: str
|
||||
|
||||
|
||||
class SubItem(Item):
|
||||
password: str
|
||||
|
||||
|
||||
def test_deprecated_from_orm_inheritance():
|
||||
new_item = SubItem(name="Hello", password="secret")
|
||||
with pytest.warns(DeprecationWarning):
|
||||
item = Item.from_orm(new_item)
|
||||
assert item.name == "Hello"
|
||||
assert not hasattr(item, "password")
|
||||
|
||||
|
||||
def test_deprecated_parse_obj():
|
||||
with pytest.warns(DeprecationWarning):
|
||||
item = Item.parse_obj({"name": "Hello"})
|
||||
assert item.name == "Hello"
|
||||
|
||||
|
||||
def test_deprecated_dict():
|
||||
with pytest.warns(DeprecationWarning):
|
||||
data = Item(name="Hello").dict()
|
||||
assert data == {"name": "Hello"}
|
||||
Reference in New Issue
Block a user