Skip to content

Commit

Permalink
Add unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
koxudaxi committed Jul 4, 2021
1 parent 4b67404 commit 33a4a21
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
15 changes: 15 additions & 0 deletions testData/inspection/extra.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from pydantic import BaseModel, Extra

class A(BaseModel):
class Config:
extra = Extra.ignore

A(a='123')


class B(BaseModel):
a: str
class Config:
extra = Extra.forbid

B(a='abc', <error descr="'b' extra fields not permitted">b='123'</error>)
2 changes: 1 addition & 1 deletion testData/mock/pydanticv1/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .main import BaseModel, BaseConfig, create_model
from .main import BaseModel, BaseConfig, create_model, Extra
from .class_validators import validator, root_validator
from .fields import Field, Schema
from .env_settings import BaseSettings
Expand Down
5 changes: 4 additions & 1 deletion testData/mock/pydanticv1/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from typing import *

from enum import Enum


class BaseModel:
class Config:
pass
Expand All @@ -11,7 +14,7 @@ def from_orm(cls, obj):
pass


class Extra(str):
class Extra(str, Enum):
allow = 'allow'
ignore = 'ignore'
forbid = 'forbid'
Expand Down
4 changes: 4 additions & 0 deletions testSrc/com/koxudaxi/pydantic/PydanticInspectionTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,8 @@ open class PydanticInspectionTest : PydanticInspectionBase() {
fun testKwargConfig() {
doTest()
}

fun testExtra() {
doTest()
}
}

0 comments on commit 33a4a21

Please sign in to comment.