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