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

Method test_pre_init_args

tests/test_make.py:740–754  ·  view source on GitHub ↗

Verify that __attrs_pre_init__ gets called with extra args if defined.

(self)

Source from the content-addressed store, hash-verified

738
739 @pytest.mark.usefixtures("with_and_without_validation")
740 def test_pre_init_args(self):
741 """
742 Verify that __attrs_pre_init__ gets called with extra args if defined.
743 """
744
745 @attr.s
746 class C:
747 x = attr.ib()
748
749 def __attrs_pre_init__(self2, x):
750 self2.z = x + 1
751
752 c = C(x=10)
753
754 assert 11 == getattr(c, "z", None)
755
756 @pytest.mark.usefixtures("with_and_without_validation")
757 def test_pre_init_kwargs(self):

Callers

nothing calls this directly

Calls 1

CClass · 0.70

Tested by

no test coverage detected