MCPcopy
hub / github.com/python-attrs/attrs / test_pre_init_kwargs

Method test_pre_init_kwargs

tests/test_make.py:757–773  ·  view source on GitHub ↗

Verify that __attrs_pre_init__ gets called with extra args and kwargs if defined.

(self)

Source from the content-addressed store, hash-verified

755
756 @pytest.mark.usefixtures("with_and_without_validation")
757 def test_pre_init_kwargs(self):
758 """
759 Verify that __attrs_pre_init__ gets called with extra args and kwargs
760 if defined.
761 """
762
763 @attr.s
764 class C:
765 x = attr.ib()
766 y = attr.field(kw_only=True)
767
768 def __attrs_pre_init__(self2, x, y):
769 self2.z = x + y + 1
770
771 c = C(10, y=11)
772
773 assert 22 == getattr(c, "z", None)
774
775 @pytest.mark.usefixtures("with_and_without_validation")
776 def test_pre_init_kwargs_only(self):

Callers

nothing calls this directly

Calls 1

CClass · 0.70

Tested by

no test coverage detected