Coverage for tests/test_deprecations.py: 100%
20 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-07 05:42 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-07 05:42 +0000
1import pytest 1abcdefg
2from sqlmodel import SQLModel 1abcdefg
5class Item(SQLModel): 1abcdefg
6 name: str 1abcdefg
9class SubItem(Item): 1abcdefg
10 password: str 1abcdefg
13def test_deprecated_from_orm_inheritance(): 1abcdefg
14 new_item = SubItem(name="Hello", password="secret") 1hijklmn
15 with pytest.warns(DeprecationWarning): 1hijklmn
16 item = Item.from_orm(new_item) 1hijklmn
17 assert item.name == "Hello" 1hijklmn
18 assert not hasattr(item, "password") 1hijklmn
21def test_deprecated_parse_obj(): 1abcdefg
22 with pytest.warns(DeprecationWarning): 1opqrstu
23 item = Item.parse_obj({"name": "Hello"}) 1opqrstu
24 assert item.name == "Hello" 1opqrstu
27def test_deprecated_dict(): 1abcdefg
28 with pytest.warns(DeprecationWarning): 1vwxyzAB
29 data = Item(name="Hello").dict() 1vwxyzAB
30 assert data == {"name": "Hello"} 1vwxyzAB