Coverage for tests/test_deprecations.py: 100%

20 statements  

« prev     ^ index     » next       coverage.py v7.17.2, created at 2026-11-16 00:02 +0000

1import pytest 1abcdefghijklm

2from sqlmodel import SQLModel 1abcdefghijklm

3 

4 

5class Item(SQLModel): 1abcdefghijklm

6 name: str 1abcdefghijklm

7 

8 

9class SubItem(Item): 1abcdefghijklm

10 password: str 1abcdefghijklm

11 

12 

13def test_deprecated_from_orm_inheritance(): 1abcdefghijklm

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

15 with pytest.warns(DeprecationWarning): 1nopqrstuvwxyz

16 item = Item.from_orm(new_item) 1nopqrstuvwxyz

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

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

19 

20 

21def test_deprecated_parse_obj(): 1abcdefghijklm

22 with pytest.warns(DeprecationWarning): 1ABCDEFGHIJKLM

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

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

25 

26 

27def test_deprecated_dict(): 1abcdefghijklm

28 with pytest.warns(DeprecationWarning): 1NOPQRSTUVWXYZ

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

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