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

Method test_post_init

tests/test_make.py:856–871  ·  view source on GitHub ↗

Verify that __attrs_post_init__ gets called if defined.

(self)

Source from the content-addressed store, hash-verified

854
855 @pytest.mark.usefixtures("with_and_without_validation")
856 def test_post_init(self):
857 """
858 Verify that __attrs_post_init__ gets called if defined.
859 """
860
861 @attr.s
862 class C:
863 x = attr.ib()
864 y = attr.ib()
865
866 def __attrs_post_init__(self2):
867 self2.z = self2.x + self2.y
868
869 c = C(x=10, y=20)
870
871 assert 30 == getattr(c, "z", None)
872
873 @pytest.mark.usefixtures("with_and_without_validation")
874 def test_pre_post_init_order(self):

Callers

nothing calls this directly

Calls 1

CClass · 0.70

Tested by

no test coverage detected