()
| 133 | |
| 134 | |
| 135 | def test_nested_dictionary_model() -> None: |
| 136 | class NestedModel(BaseModel): |
| 137 | nested: Dict[str, BasicModel] |
| 138 | |
| 139 | m = NestedModel.construct(nested={"hello": {"foo": "bar"}}) |
| 140 | assert isinstance(m.nested, dict) |
| 141 | assert m.nested["hello"].foo == "bar" |
| 142 | |
| 143 | # mismatched types |
| 144 | m = NestedModel.construct(nested={"hello": False}) |
| 145 | assert cast(Any, m.nested["hello"]) is False |
| 146 | |
| 147 | |
| 148 | def test_unknown_fields() -> None: |