Coverage for tests/test_missing_type.py: 100%

13 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-09-09 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): 1fabcde

10 @classmethod 1fabcde

11 def __get_validators__(cls): 1abcde

12 yield cls.validate 1fabcde

13 

14 @classmethod 1fabcde

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

16 return v 

17 

18 with pytest.raises(ValueError): 1fabcde

19 

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

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

22 item: CustomType 1fabcde