Coverage for tests/test_missing_type.py: 92%

12 statements  

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

1import pytest 1nopqrstuvwxyz

2from pydantic import BaseModel 1nopqrstuvwxyz

3from sqlmodel import Field, SQLModel 1nopqrstuvwxyz

4 

5 

6def test_missing_sql_type(): 1nopqrstuvwxyz

7 class CustomType(BaseModel): 1abcdefghijklm

8 @classmethod 1abcdefghijklm

9 def __get_validators__(cls): 1abcdefghijklm

10 yield cls.validate 

11 

12 @classmethod 1abcdefghijklm

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

14 return v 

15 

16 with pytest.raises(ValueError): 1abcdefghijklm

17 

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

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

20 item: CustomType 1abcdefghijklm