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

Method test_pre_init_kwargs_only

tests/test_make.py:776–791  ·  view source on GitHub ↗

Verify that __attrs_pre_init__ gets called with extra kwargs only if defined.

(self)

Source from the content-addressed store, hash-verified

774
775 @pytest.mark.usefixtures("with_and_without_validation")
776 def test_pre_init_kwargs_only(self):
777 """
778 Verify that __attrs_pre_init__ gets called with extra kwargs only if
779 defined.
780 """
781
782 @attr.s
783 class C:
784 y = attr.field(kw_only=True)
785
786 def __attrs_pre_init__(self2, y):
787 self2.z = y + 1
788
789 c = C(y=11)
790
791 assert 12 == getattr(c, "z", None)
792
793 @pytest.mark.usefixtures("with_and_without_validation")
794 def test_pre_init_kw_only_work_with_defaults(self):

Callers

nothing calls this directly

Calls 1

CClass · 0.70

Tested by

no test coverage detected