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

Method test_converter_factory_property

tests/test_make.py:1743–1761  ·  view source on GitHub ↗

Property tests for attributes with converter, and a factory default.

(self, val, init)

Source from the content-addressed store, hash-verified

1741
1742 @given(integers(), booleans())
1743 def test_converter_factory_property(self, val, init):
1744 """
1745 Property tests for attributes with converter, and a factory default.
1746 """
1747 C = make_class(
1748 "C",
1749 {
1750 "y": attr.ib(),
1751 "x": attr.ib(
1752 init=init,
1753 default=Factory(lambda: val),
1754 converter=lambda v: v + 1,
1755 ),
1756 },
1757 )
1758 c = C(2)
1759
1760 assert c.x == val + 1
1761 assert c.y == 2
1762
1763 def test_convert_before_validate(self):
1764 """

Callers

nothing calls this directly

Calls 3

make_classFunction · 0.90
FactoryClass · 0.90
CClass · 0.70

Tested by

no test coverage detected