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

Method test_validator_decorator

tests/test_make.py:122–137  ·  view source on GitHub ↗

If _CountingAttr.validator is used as a decorator and there is already a decorator set, the decorators are composed using `and_`.

(self, wrap)

Source from the content-addressed store, hash-verified

120
121 @pytest.mark.parametrize("wrap", [lambda v: v, lambda v: [v], and_])
122 def test_validator_decorator(self, wrap):
123 """
124 If _CountingAttr.validator is used as a decorator and there is already
125 a decorator set, the decorators are composed using `and_`.
126 """
127
128 def v(_, __):
129 pass
130
131 a = attr.ib(validator=wrap(v))
132
133 @a.validator
134 def v2(self, _, __):
135 pass
136
137 assert _AndValidator((v, v2)) == a._validator
138
139 def test_default_decorator_already_set(self):
140 """

Callers

nothing calls this directly

Calls 2

_AndValidatorClass · 0.90
wrapFunction · 0.50

Tested by

no test coverage detected