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

Method test_fail

tests/test_validators.py:356–369  ·  view source on GitHub ↗

Raises `TypeError` on wrong types.

(self, validator)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

optionalFunction · 0.90
simple_attrFunction · 0.85

Tested by

no test coverage detected