Coverage for tests / test_deprecations.py: 100%

20 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-06-10 09:40 +0000

1import pytest 1abcdefgh

2from sqlmodel import SQLModel 1abcdefgh

3 

4 

5class Item(SQLModel): 1abcdefgh

6 name: str 1abcdefgh

7 

8 

9class SubItem(Item): 1abcdefgh

10 password: str 1abcdefgh

11 

12 

13def test_deprecated_from_orm_inheritance(): 1abcdefgh

14 new_item = SubItem(name="Hello", password="secret") 1ijklmnop

15 with pytest.warns(DeprecationWarning): 1ijklmnop

16 item = Item.from_orm(new_item) 1ijklmnop

17 assert item.name == "Hello" 1ijklmnop

18 assert not hasattr(item, "password") 1ijklmnop

19 

20 

21def test_deprecated_parse_obj(): 1abcdefgh

22 with pytest.warns(DeprecationWarning): 1qrstuvwx

23 item = Item.parse_obj({"name": "Hello"}) 1qrstuvwx

24 assert item.name == "Hello" 1qrstuvwx

25 

26 

27def test_deprecated_dict(): 1abcdefgh

28 with pytest.warns(DeprecationWarning): 1yzABCDEF

29 data = Item(name="Hello").dict() 1yzABCDEF

30 assert data == {"name": "Hello"} 1yzABCDEF