diff options
Diffstat (limited to 'test/ext/declarative/test_basic.py')
-rw-r--r-- | test/ext/declarative/test_basic.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/ext/declarative/test_basic.py b/test/ext/declarative/test_basic.py index d2dc1a425..e8a9a140c 100644 --- a/test/ext/declarative/test_basic.py +++ b/test/ext/declarative/test_basic.py @@ -1,6 +1,7 @@ from sqlalchemy.testing import eq_, assert_raises, \ assert_raises_message, expect_warnings, is_ +from sqlalchemy.testing import assertions from sqlalchemy.ext import declarative as decl from sqlalchemy.ext.hybrid import hybrid_property from sqlalchemy import exc @@ -175,6 +176,62 @@ class DeclarativeTest(DeclarativeTestBase): assert class_mapper(Bar).get_property('some_data').columns[0] \ is t.c.data + def test_lower_case_c_column_warning(self): + with assertions.expect_warnings( + r"Attribute 'x' on class <class .*Foo.* appears to be a " + r"non-schema 'sqlalchemy.sql.column\(\)' object; ", + ): + class Foo(Base): + __tablename__ = 'foo' + + id = Column(Integer, primary_key=True) + x = sa.sql.expression.column(Integer) + y = Column(Integer) + + class MyMixin(object): + x = sa.sql.expression.column(Integer) + y = Column(Integer) + + with assertions.expect_warnings( + r"Attribute 'x' on class <class .*MyMixin.* appears to be a " + r"non-schema 'sqlalchemy.sql.column\(\)' object; ", + ): + class Foo2(MyMixin, Base): + __tablename__ = 'foo2' + + id = Column(Integer, primary_key=True) + + with assertions.expect_warnings( + r"Attribute 'x' on class <class .*Foo3.* appears to be a " + r"non-schema 'sqlalchemy.sql.column\(\)' object; ", + ): + class Foo3(Base): + __tablename__ = 'foo3' + + id = Column(Integer, primary_key=True) + + @declared_attr + def x(cls): + return sa.sql.expression.column(Integer) + + y = Column(Integer) + + with assertions.expect_warnings( + r"Attribute 'x' on class <class .*Foo4.* appears to be a " + r"non-schema 'sqlalchemy.sql.column\(\)' object; ", + ): + class MyMixin2(object): + @declared_attr + def x(cls): + return sa.sql.expression.column(Integer) + + y = Column(Integer) + + class Foo4(MyMixin2, Base): + __tablename__ = 'foo4' + + id = Column(Integer, primary_key=True) + def test_column_named_twice(self): def go(): class Foo(Base): |