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

Method test_pre_post_init_order

tests/test_make.py:874–891  ·  view source on GitHub ↗

Verify that __attrs_post_init__ gets called if defined.

(self)

Source from the content-addressed store, hash-verified

872
873 @pytest.mark.usefixtures("with_and_without_validation")
874 def test_pre_post_init_order(self):
875 """
876 Verify that __attrs_post_init__ gets called if defined.
877 """
878
879 @attr.s
880 class C:
881 x = attr.ib()
882
883 def __attrs_pre_init__(self2):
884 self2.z = 30
885
886 def __attrs_post_init__(self2):
887 self2.z += self2.x
888
889 c = C(x=10)
890
891 assert 40 == getattr(c, "z", None)
892
893 def test_types(self):
894 """

Callers

nothing calls this directly

Calls 1

CClass · 0.70

Tested by

no test coverage detected