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

Method test_fail

tests/test_validators.py:356–369  ·  tests/test_validators.py::TestOptional.test_fail

Raises `TypeError` on wrong types.

(self, validator)

Source from the content-addressed store, hash-verified

354 v(None, simple_attr(class="st">"test"), None)
355
356 def test_fail(self, validator):
357 class="st">"""
358 Raises `TypeError` on wrong types.
359 class="st">"""
360 v = optional(validator)
361 a = simple_attr(class="st">"test")
362 with pytest.raises(TypeError) as e:
363 v(None, a, class="st">"42")
364 assert (
365 class="st">"&class="cm">#x27;test' must be <class 'int'> (got '42' that is a <class 'str'>).",
366 a,
367 int,
368 class="st">"42",
369 ) == e.value.args
370
371 def test_repr(self, validator):
372 class="st">"""

Callers

nothing calls this directly

Calls 2

optionalFunction · 0.90
simple_attrFunction · 0.85

Tested by

no test coverage detected