MCPcopy
hub / github.com/msgspec/msgspec / test_dict_constrs

Method test_dict_constrs

tests/unit/test_convert.py:1242–1253  ·  view source on GitHub ↗
(self, dictcls)

Source from the content-addressed store, hash-verified

1240 convert(msg, Cache)
1241
1242 def test_dict_constrs(self, dictcls):
1243 class Ex(Struct):
1244 x: Annotated[dict, Meta(min_length=2, max_length=4)]
1245
1246 for n in [2, 4]:
1247 x = dictcls({str(i): i for i in range(n)})
1248 assert convert(dictcls({"x": x}), Ex).x == x
1249
1250 for n in [1, 5]:
1251 x = {str(i): i for i in range(n)}
1252 with pytest.raises(ValidationError):
1253 convert(dictcls({"x": x}), Ex)
1254
1255
1256class TestTypedDict:

Callers

nothing calls this directly

Calls 1

dictclsFunction · 0.85

Tested by

no test coverage detected