Coverage for tests / test_deprecations.py: 100%

20 statements  

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

1import pytest 1abcdefghi

2from sqlmodel import SQLModel 1abcdefghi

3 

4 

5class Item(SQLModel): 1abcdefghi

6 name: str 1abcdefghi

7 

8 

9class SubItem(Item): 1abcdefghi

10 password: str 1abcdefghi

11 

12 

13def test_deprecated_from_orm_inheritance(): 1abcdefghi

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

15 with pytest.warns(DeprecationWarning): 1jklmnopqr

16 item = Item.from_orm(new_item) 1jklmnopqr

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

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

19 

20 

21def test_deprecated_parse_obj(): 1abcdefghi

22 with pytest.warns(DeprecationWarning): 1stuvwxyzA

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

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

25 

26 

27def test_deprecated_dict(): 1abcdefghi

28 with pytest.warns(DeprecationWarning): 1BCDEFGHIJ

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

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