eq_(bind_processor("foo"), "foo")
assert_raises_message(
LookupError,
- '"5" is not among the defined enum values',
+ "'5' is not among the defined enum values. Enum name: someenum. "
+ "Possible values: one, two, three, ..., BMember",
bind_processor,
5,
)
assert_raises_message(
LookupError,
- '"foo" is not among the defined enum values',
+ "'foo' is not among the defined enum values. Enum name: someenum. "
+ "Possible values: one, two, three, ..., BMember",
bind_processor_validates,
"foo",
)
eq_(result_processor("one"), self.one)
assert_raises_message(
LookupError,
- '"foo" is not among the defined enum values',
+ "'foo' is not among the defined enum values. Enum name: someenum. "
+ "Possible values: one, two, three, ..., BMember",
result_processor,
"foo",
)
assert_raises_message(
LookupError,
- '"5" is not among the defined enum values',
+ "'5' is not among the defined enum values. Enum name: someenum. "
+ "Possible values: one, two, three, ..., BMember",
literal_processor,
5,
)
assert_raises_message(
LookupError,
- '"foo" is not among the defined enum values',
+ "'foo' is not among the defined enum values. Enum name: someenum. "
+ "Possible values: one, two, three, ..., BMember",
validate_literal_processor,
"foo",
)
eq_(bind_processor("foo"), "foo")
assert_raises_message(
LookupError,
- '"5" is not among the defined enum values',
+ "'5' is not among the defined enum values. Enum name: None. "
+ "Possible values: one, two",
bind_processor,
5,
)
assert_raises_message(
LookupError,
- '"foo" is not among the defined enum values',
+ "'foo' is not among the defined enum values. Enum name: None. "
+ "Possible values: one, two",
bind_processor_validates,
"foo",
)
eq_(result_processor("one"), "one")
assert_raises_message(
LookupError,
- '"foo" is not among the defined enum values',
+ "'foo' is not among the defined enum values. Enum name: None. "
+ "Possible values: one, two",
result_processor,
"foo",
)
eq_(literal_processor("foo"), "'foo'")
assert_raises_message(
LookupError,
- '"5" is not among the defined enum values',
+ "'5' is not among the defined enum values. Enum name: None. "
+ "Possible values: one, two",
literal_processor,
5,
)
assert_raises_message(
LookupError,
- '"foo" is not among the defined enum values',
+ "'foo' is not among the defined enum values. Enum name: None. "
+ "Possible values: one, two",
validate_literal_processor,
"foo",
)
+ def test_enum_raise_lookup_ellipses(self):
+ type_ = Enum("one", "twothreefourfivesix", "seven", "eight")
+ bind_processor = type_.bind_processor(testing.db.dialect)
+
+ eq_(bind_processor("one"), "one")
+ assert_raises_message(
+ LookupError,
+ "'5' is not among the defined enum values. Enum name: None. "
+ "Possible values: one, twothreefou.., seven, eight",
+ bind_processor,
+ 5,
+ )
+
+ def test_enum_raise_lookup_none(self):
+ type_ = Enum()
+ bind_processor = type_.bind_processor(testing.db.dialect)
+
+ assert_raises_message(
+ LookupError,
+ "'5' is not among the defined enum values. Enum name: None. "
+ "Possible values: None",
+ bind_processor,
+ 5,
+ )
+
def test_validators_not_in_like_roundtrip(self, connection):
enum_table = self.tables["non_native_enum_table"]
)
assert_raises_message(
LookupError,
- '"four" is not among the defined enum values',
+ "'four' is not among the defined enum values. "
+ "Enum name: None. Possible values: one, two, three",
conn.scalar,
select([self.tables.non_native_enum_table.c.someotherenum]),
)