(self, dictcls)
| 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 | |
| 1256 | class TestTypedDict: |