()
| 10 | |
| 11 | |
| 12 | def test_private_attribute(): |
| 13 | default = {'a': {}} |
| 14 | |
| 15 | class Model(BaseModel): |
| 16 | _foo = PrivateAttr(default) |
| 17 | |
| 18 | assert set(Model.__private_attributes__) == {'_foo'} |
| 19 | |
| 20 | m = Model() |
| 21 | assert m._foo == default |
| 22 | assert m._foo is not default |
| 23 | assert m._foo['a'] is not default['a'] |
| 24 | |
| 25 | m._foo = None |
| 26 | assert m._foo is None |
| 27 | |
| 28 | assert m.model_dump() == {} |
| 29 | assert m.__dict__ == {} |
| 30 | |
| 31 | |
| 32 | def test_private_attribute_double_leading_underscore(): |
nothing calls this directly
no test coverage detected