Coverage for tests / test_missing_type.py: 92%

12 statements  

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

1import pytest 1ijklmnop

2from pydantic import BaseModel 1ijklmnop

3from sqlmodel import Field, SQLModel 1ijklmnop

4 

5 

6def test_missing_sql_type(): 1ijklmnop

7 class CustomType(BaseModel): 1abcdefgh

8 @classmethod 1abcdefgh

9 def __get_validators__(cls): 1abcdefgh

10 yield cls.validate 

11 

12 @classmethod 1abcdefgh

13 def validate(cls, v): # pragma: no cover 1abcdefgh

14 return v 

15 

16 with pytest.raises(ValueError): 1abcdefgh

17 

18 class Item(SQLModel, table=True): 1abcdefgh

19 id: int | None = Field(default=None, primary_key=True) 1abcdefgh

20 item: CustomType 1abcdefgh