Coverage for tests/test_missing_type.py: 100%
13 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-12 19:13 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-12 19:13 +0000
1from typing import Optional 1feabcd
3import pytest 1feabcd
4from pydantic import BaseModel 1feabcd
5from sqlmodel import Field, SQLModel 1feabcd
8def test_missing_sql_type(): 1feabcd
9 class CustomType(BaseModel): 1feabcd
10 @classmethod 1feabcd
11 def __get_validators__(cls): 1eabcd
12 yield cls.validate 1abcd
14 @classmethod 1feabcd
15 def validate(cls, v): # pragma: no cover 1eabcd
16 return v
18 with pytest.raises(ValueError): 1feabcd
20 class Item(SQLModel, table=True): 1feabcd
21 id: Optional[int] = Field(default=None, primary_key=True) 1feabcd
22 item: CustomType 1feabcd