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

Method test_init

tests/test_dunders.py:747–762  ·  view source on GitHub ↗

If `init` is False, ignore that attribute.

(self, slots, frozen)

Source from the content-addressed store, hash-verified

745
746 @given(booleans(), booleans())
747 def test_init(self, slots, frozen):
748 """
749 If `init` is False, ignore that attribute.
750 """
751 C = make_class(
752 "C",
753 {"a": attr.ib(init=False), "b": attr.ib()},
754 slots=slots,
755 frozen=frozen,
756 )
757 with pytest.raises(TypeError) as e:
758 C(a=1, b=2)
759
760 assert e.value.args[0].endswith(
761 "__init__() got an unexpected keyword argument 'a'"
762 )
763
764 @given(booleans(), booleans())
765 def test_no_init_default(self, slots, frozen):

Callers

nothing calls this directly

Calls 2

make_classFunction · 0.90
CClass · 0.70

Tested by

no test coverage detected