Coverage for tests/test_missing_type.py: 100%

13 statements  

« prev     ^ index     » next       coverage.py v7.7.1, created at 2025-03-24 00:02 +0000

1from typing import Optional 1ghijkl

2 

3import pytest 1ghijkl

4from pydantic import BaseModel 1ghijkl

5from sqlmodel import Field, SQLModel 1ghijkl

6 

7 

8def test_missing_sql_type(): 1ghijkl

9 class CustomType(BaseModel): 1abcdef

10 @classmethod 1abcdef

11 def __get_validators__(cls): 1abcdef

12 yield cls.validate 1abcdef

13 

14 @classmethod 1abcdef

15 def validate(cls, v): # pragma: no cover 1abcdef

16 return v 

17 

18 with pytest.raises(ValueError): 1abcdef

19 

20 class Item(SQLModel, table=True): 1abcdef

21 id: Optional[int] = Field(default=None, primary_key=True) 1abcdef

22 item: CustomType 1abcdef