def eq_ignore_whitespace(a, b, msg=None):
a = re.sub(r"^\s+?|\n", "", a)
a = re.sub(r" {2,}", " ", a)
+ a = re.sub(r"\t", "", a)
b = re.sub(r"^\s+?|\n", "", b)
b = re.sub(r" {2,}", " ", b)
+ b = re.sub(r"\t", "", b)
assert a == b, msg or "%r != %r" % (a, b)
from sqlalchemy.testing import ComparesTables
from sqlalchemy.testing import emits_warning
from sqlalchemy.testing import eq_
+from sqlalchemy.testing import eq_ignore_whitespace
from sqlalchemy.testing import expect_raises_message
from sqlalchemy.testing import fixtures
from sqlalchemy.testing import is_
t2 = Table("t2", m, Column("x", Integer, ForeignKey("bar.t1.x")))
assert t2.c.x.references(t1.c.x)
+ @testing.combinations(
+ (schema.CreateSchema("sa_schema"), "CREATE SCHEMA sa_schema"),
+ # note we don't yet support lower-case table() or
+ # lower-case column() for this
+ # (
+ # schema.CreateTable(table("t", column("q", Integer))),
+ # "CREATE TABLE t (q INTEGER)",
+ # ),
+ (
+ schema.CreateTable(Table("t", MetaData(), Column("q", Integer))),
+ "CREATE TABLE t (q INTEGER)",
+ ),
+ (
+ schema.CreateIndex(
+ Index(
+ "foo",
+ "x",
+ _table=Table("t", MetaData(), Column("x", Integer)),
+ )
+ ),
+ "CREATE INDEX foo ON t (x)",
+ ),
+ )
+ def test_stringify_schema_elements(self, element, expected):
+ eq_ignore_whitespace(str(element), expected)
+
def test_create_drop_schema(self):
self.assert_compile(