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

Method test_converter

tests/test_make.py:1671–1681  ·  tests/test_make.py::TestConverter.test_converter

Return value of converter is used as the attribute's value.

(self)

Source from the content-addressed store, hash-verified

1669 class="st">"""
1670
1671 def test_converter(self):
1672 class="st">"""
1673 Return value of converter is used as the attribute&class="cm">#x27;s value.
1674 class="st">"""
1675 C = make_class(
1676 class="st">"C", {class="st">"x": attr.ib(converter=lambda v: v + 1), class="st">"y": attr.ib()}
1677 )
1678 c = C(1, 2)
1679
1680 assert c.x == 2
1681 assert c.y == 2
1682
1683 def test_converter_wrapped_takes_self(self):
1684 class="st">"""

Callers

nothing calls this directly

Calls 2

make_classFunction · 0.90
CClass · 0.70

Tested by

no test coverage detected