summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2017-09-27 15:37:18 -0400
committerGerrit Code Review <gerrit@ci.zzzcomputing.com>2017-09-27 15:37:18 -0400
commit5aa892995a8ccca90a84eb220de8db42949f16e6 (patch)
treed62965e51107442080dd5ba83962888943425bb9 /test
parentdc4d1ee7bdf8f9670057e916a29f1f5252e77207 (diff)
parentec1700ba29f7f15859ee6576855a4d6675265640 (diff)
downloadsqlalchemy-5aa892995a8ccca90a84eb220de8db42949f16e6.tar.gz
Merge "Warnings for @declared_attr.cascading"
Diffstat (limited to 'test')
-rw-r--r--test/ext/declarative/test_mixin.py41
1 files changed, 40 insertions, 1 deletions
diff --git a/test/ext/declarative/test_mixin.py b/test/ext/declarative/test_mixin.py
index be169bcda..0b1b117fb 100644
--- a/test/ext/declarative/test_mixin.py
+++ b/test/ext/declarative/test_mixin.py
@@ -1,5 +1,5 @@
from sqlalchemy.testing import eq_, assert_raises, \
- assert_raises_message, is_
+ assert_raises_message, is_, expect_warnings
from sqlalchemy.ext import declarative as decl
import sqlalchemy as sa
from sqlalchemy import testing
@@ -1613,6 +1613,30 @@ class DeclaredAttrTest(DeclarativeTestBase, testing.AssertsCompiledSQL):
eq_(counter.mock_calls, [mock.call(A), mock.call(B)])
+ def test_property_cascade_mixin_override(self):
+ counter = mock.Mock()
+
+ class Mixin(object):
+ @declared_attr.cascading
+ def my_prop(cls):
+ counter(cls)
+ return column_property(cls.x + 2)
+
+ class A(Base, Mixin):
+ __tablename__ = 'a'
+
+ id = Column(Integer, primary_key=True)
+ x = Column(Integer)
+
+ with expect_warnings(
+ "Attribute 'my_prop' on class .*B.* "
+ "cannot be processed due to @declared_attr.cascading; "
+ "skipping"):
+ class B(A):
+ my_prop = Column('foobar', Integer)
+
+ eq_(counter.mock_calls, [mock.call(A), mock.call(B)])
+
def test_property_cascade_abstract(self):
counter = mock.Mock()
@@ -1635,6 +1659,21 @@ class DeclaredAttrTest(DeclarativeTestBase, testing.AssertsCompiledSQL):
eq_(counter.mock_calls, [mock.call(A), mock.call(B)])
+ def test_warn_cascading_used_w_tablename(self):
+ class Mixin(object):
+ @declared_attr.cascading
+ def __tablename__(cls):
+ return "foo"
+
+ with expect_warnings(
+ "@declared_attr.cascading is not supported on the "
+ "__tablename__ attribute on class .*A."
+ ):
+ class A(Mixin, Base):
+ id = Column(Integer, primary_key=True)
+
+ eq_(A.__table__.name, "foo")
+
def test_col_prop_attrs_associated_w_class_for_mapper_args(self):
from sqlalchemy import Column
import collections