for item in args:
if item is not None:
- item._set_parent_with_dispatch(self)
+ try:
+ spwd = item._set_parent_with_dispatch
+ except AttributeError:
+ raise exc.ArgumentError(
+ "'SchemaItem' object, such as a 'Column' or a "
+ "'Constraint' expected, got %r" % item
+ )
+ else:
+ spwd(self)
def get_children(self, **kwargs):
"""used to allow SchemaVisitor access"""
t.info["bar"] = "zip"
assert t.info["bar"] == "zip"
+ def test_invalid_objects(self):
+ assert_raises_message(
+ tsa.exc.ArgumentError,
+ "'SchemaItem' object, such as a 'Column' or a "
+ "'Constraint' expected, got <.*ColumnClause at .*; q>",
+ Table,
+ "asdf",
+ MetaData(),
+ tsa.column("q", Integer),
+ )
+
+ assert_raises_message(
+ tsa.exc.ArgumentError,
+ r"'SchemaItem' object, such as a 'Column' or a "
+ r"'Constraint' expected, got String\(\)",
+ Table,
+ "asdf",
+ MetaData(),
+ String(),
+ )
+
+ assert_raises_message(
+ tsa.exc.ArgumentError,
+ "'SchemaItem' object, such as a 'Column' or a "
+ "'Constraint' expected, got 12",
+ Table,
+ "asdf",
+ MetaData(),
+ 12,
+ )
+
def test_reset_exported_passes(self):
m = MetaData()