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