1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 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"}
|