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

Method test_fail

tests/test_validators.py:144–157  ·  tests/test_validators.py::TestInstanceOf.test_fail

Raises `TypeError` on wrong types.

(self)

Source from the content-addressed store, hash-verified

142 v(None, simple_attr(class="st">"test"), True)
143
144 def test_fail(self):
145 class="st">"""
146 Raises `TypeError` on wrong types.
147 class="st">"""
148 v = instance_of(int)
149 a = simple_attr(class="st">"test")
150 with pytest.raises(TypeError) as e:
151 v(None, a, class="st">"42")
152 assert (
153 class="st">"&class="cm">#x27;test' must be <class 'int'> (got '42' that is a <class 'str'>).",
154 a,
155 int,
156 class="st">"42",
157 ) == e.value.args
158
159 def test_repr(self):
160 class="st">"""

Callers

nothing calls this directly

Calls 2

instance_ofFunction · 0.90
simple_attrFunction · 0.85

Tested by

no test coverage detected