fix coverage for 'conset()' (#1704)

This commit is contained in:
Samuel Colvin
2020-07-11 11:24:24 +01:00
committed by GitHub
parent 527c35a856
commit 853a6bbb76
2 changed files with 8 additions and 3 deletions
-3
View File
@@ -190,9 +190,6 @@ class ConstrainedSet(set): # type: ignore
@classmethod
def set_length_validator(cls, v: 'Optional[Set[T]]', field: 'ModelField') -> 'Optional[Set[T]]':
if v is None and not field.required:
return None
v = set_validator(v)
v_len = len(v)
+8
View File
@@ -405,6 +405,14 @@ def test_conset():
assert exc_info.value.errors() == [{'loc': ('foo',), 'msg': 'value is not a valid set', 'type': 'type_error.set'}]
def test_conset_not_required():
class Model(BaseModel):
foo: Set[int] = None
assert Model(foo=None).foo is None
assert Model().foo is None
class ConStringModel(BaseModel):
v: constr(max_length=10) = 'foobar'