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

Method test_unknown

tests/test_funcs.py:707–723  ·  view source on GitHub ↗

Wanting to change an unknown attribute raises an AttrsAttributeNotFoundError.

(self, C)

Source from the content-addressed store, hash-verified

705
706 @given(simple_classes())
707 def test_unknown(self, C):
708 """
709 Wanting to change an unknown attribute raises an
710 AttrsAttributeNotFoundError.
711 """
712 # No generated class will have a four letter attribute.
713 with pytest.raises(TypeError) as e:
714 evolve(C(), aaaa=2)
715
716 if hasattr(C, "__attrs_init__"):
717 expected = (
718 "__attrs_init__() got an unexpected keyword argument 'aaaa'"
719 )
720 else:
721 expected = "__init__() got an unexpected keyword argument 'aaaa'"
722
723 assert e.value.args[0].endswith(expected)
724
725 def test_validator_failure(self):
726 """

Callers

nothing calls this directly

Calls 2

evolveFunction · 0.90
CClass · 0.70

Tested by

no test coverage detected