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

Method test_falsey_converter

tests/test_converters.py:115–132  ·  view source on GitHub ↗

Passing a false-y instance still produces a valid converter.

(self)

Source from the content-addressed store, hash-verified

113 assert None is c2.__call__.__annotations__.get("return")
114
115 def test_falsey_converter(self):
116 """
117 Passing a false-y instance still produces a valid converter.
118 """
119
120 class MyConv:
121 def __bool__(self):
122 return False
123
124 def __call__(self, value):
125 return value * 2
126
127 @attr.s
128 class C:
129 a = attrib(converter=MyConv())
130
131 c = C(21)
132 assert 42 == c.a
133
134
135class TestOptional:

Callers

nothing calls this directly

Calls 1

CClass · 0.70

Tested by

no test coverage detected