()
| 148 | |
| 149 | |
| 150 | def test_nested_dictionary_model() -> None: |
| 151 | class NestedModel(BaseModel): |
| 152 | nested: Dict[str, BasicModel] |
| 153 | |
| 154 | m = NestedModel.construct(nested={"hello": {"foo": "bar"}}) |
| 155 | assert isinstance(m.nested, dict) |
| 156 | assert m.nested["hello"].foo == "bar" |
| 157 | |
| 158 | # mismatched types |
| 159 | m = NestedModel.construct(nested={"hello": False}) |
| 160 | assert cast(Any, m.nested["hello"]) is False |
| 161 | |
| 162 | |
| 163 | def test_unknown_fields() -> None: |