def test_type_cast_exception():
"""Make sure our type casting exceptions are informative"""
class A(Enumap):
a: int = auto()
this_here_is_a_bad_key: int = auto()
assert A.tuple_casted("1", "2") == (1, 2)
with pytest.raises(TypeCastError) as e:
A.tuple_casted("1", None)
assert "'this_here_is_a_bad_key' got invalid value 'None'" in str(e)
assert "of type NoneType" in str(e)
assert e.value.key == "this_here_is_a_bad_key"
评论列表
文章目录