summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2018-12-02 18:54:40 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2018-12-02 18:59:45 -0500
commit5945da4e41370bc71a0d3f811ea128be5663db6e (patch)
tree4ea5cbdebed2fcbb343a6add7e31c692414fe12c
parent039d8a31f59fa8241d30a79c2ab4d05546156d31 (diff)
downloadsqlalchemy-5945da4e41370bc71a0d3f811ea128be5663db6e.tar.gz
"left" -> "accidentally placed at"
since "left" is kind of ambiguous, use more explicit terminology here. Also update the test to use a positive assertion that the warning is emitted; quote the attribute name. Change-Id: Ic2284c200a26b32b2da063cfaf6d59547309d587 References: https://github.com/zzzeek/sqlalchemy/pull/488 (cherry picked from commit eacb31a89fe883edd0ada7f2724239c1f8c5b685)
-rw-r--r--lib/sqlalchemy/ext/declarative/base.py4
-rw-r--r--test/ext/declarative/test_basic.py16
2 files changed, 7 insertions, 13 deletions
diff --git a/lib/sqlalchemy/ext/declarative/base.py b/lib/sqlalchemy/ext/declarative/base.py
index a41a46848..b580a79e0 100644
--- a/lib/sqlalchemy/ext/declarative/base.py
+++ b/lib/sqlalchemy/ext/declarative/base.py
@@ -386,8 +386,8 @@ class _MapperConfig(object):
if (isinstance(value, tuple) and len(value) == 1 and
isinstance(value[0], (Column, MapperProperty))):
util.warn("Ignoring declarative-like tuple value of attribute "
- "%s: possibly a copy-and-paste error with a comma "
- "left at the end of the line?" % k)
+ "'%s': possibly a copy-and-paste error with a comma "
+ "accidentally placed at the end of the line?" % k)
continue
elif not isinstance(value, (Column, MapperProperty)):
# using @declared_attr for some object that
diff --git a/test/ext/declarative/test_basic.py b/test/ext/declarative/test_basic.py
index 3eb0743e7..7996fcee8 100644
--- a/test/ext/declarative/test_basic.py
+++ b/test/ext/declarative/test_basic.py
@@ -1122,23 +1122,17 @@ class DeclarativeTest(DeclarativeTestBase):
eq_(Foo.__mapper__.CHECK, True)
- @testing.emits_warning('Ignoring declarative-like tuple value of '
- 'attribute id')
def test_oops(self):
- def define():
+ with testing.expect_warnings(
+ "Ignoring declarative-like tuple value of "
+ "attribute 'name'"):
class User(Base, fixtures.ComparableEntity):
__tablename__ = 'users'
- id = Column('id', Integer, primary_key=True),
- name = Column('name', String(50))
-
- assert False
-
- assert_raises_message(sa.exc.ArgumentError,
- 'Mapper Mapper|User|users could not '
- 'assemble any primary key', define)
+ id = Column('id', Integer, primary_key=True)
+ name = Column('name', String(50)),
def test_table_args_no_dict(self):