File: test_deprecations.py

package info (click to toggle)
sqlmodel 0.0.24-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,128 kB
  • sloc: python: 34,496; javascript: 280; sh: 15; makefile: 7
file content (30 lines) | stat: -rw-r--r-- 690 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import pytest
from sqlmodel import SQLModel


class Item(SQLModel):
    name: str


class SubItem(Item):
    password: str


def test_deprecated_from_orm_inheritance():
    new_item = SubItem(name="Hello", password="secret")
    with pytest.warns(DeprecationWarning):
        item = Item.from_orm(new_item)
    assert item.name == "Hello"
    assert not hasattr(item, "password")


def test_deprecated_parse_obj():
    with pytest.warns(DeprecationWarning):
        item = Item.parse_obj({"name": "Hello"})
    assert item.name == "Hello"


def test_deprecated_dict():
    with pytest.warns(DeprecationWarning):
        data = Item(name="Hello").dict()
    assert data == {"name": "Hello"}