Skip to content

Commit

Permalink
"left" -> "accidentally placed at"
Browse files Browse the repository at this point in the history
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: #488
  • Loading branch information
zzzeek committed Dec 2, 2018
1 parent c8dea35 commit eacb31a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
4 changes: 2 additions & 2 deletions lib/sqlalchemy/ext/declarative/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,8 @@ def _extract_mappable_attributes(self):
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
Expand Down
16 changes: 5 additions & 11 deletions test/ext/declarative/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1170,23 +1170,17 @@ class Foo(base):

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):

Expand Down

0 comments on commit eacb31a

Please sign in to comment.