From bbdc8e80385a08a6b0a3bbf8a2ded92d466936e2 Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Mon, 5 Aug 2019 11:35:49 +0100 Subject: [PATCH] add test_init_inspection --- tests/test_edge_cases.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_edge_cases.py b/tests/test_edge_cases.py index e2b313f..5716060 100644 --- a/tests/test_edge_cases.py +++ b/tests/test_edge_cases.py @@ -1005,3 +1005,15 @@ def test_values_attr_deprecation(): m = Model(foo=4, bar='baz') with pytest.warns(DeprecationWarning, match='`__values__` attribute is deprecated, use `__dict__` instead'): assert m.__values__ == m.__dict__ + + +def test_init_inspection(): + class Foobar(BaseModel): + x: int + + def __init__(self, **data) -> None: + with pytest.raises(AttributeError): + assert self.x + super().__init__(**data) + + Foobar(x=1)