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

Method test_fail

tests/test_validators.py:416–431  ·  view source on GitHub ↗

Raise ValueError if the value is outside our options.

(self)

Source from the content-addressed store, hash-verified

414 v(1, a, 3)
415
416 def test_fail(self):
417 """
418 Raise ValueError if the value is outside our options.
419 """
420 v = in_([1, 2, 3])
421 a = simple_attr("test")
422
423 with pytest.raises(ValueError) as e:
424 v(None, a, None)
425
426 assert (
427 "'test' must be in [1, 2, 3] (got None)",
428 a,
429 [1, 2, 3],
430 None,
431 ) == e.value.args
432
433 def test_fail_with_string(self):
434 """

Callers

nothing calls this directly

Calls 2

in_Function · 0.90
simple_attrFunction · 0.85

Tested by

no test coverage detected