]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
"left" -> "accidentally placed at"
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 2 Dec 2018 23:54:40 +0000 (18:54 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 2 Dec 2018 23:58:47 +0000 (18:58 -0500)
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

lib/sqlalchemy/ext/declarative/base.py
test/ext/declarative/test_basic.py

index f1d75bb4b22392bfc087380930e9dfef07971fbe..f27314b5e6fc9cd8c711c834f079fe88debe0b15 100644 (file)
@@ -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
index 611598413a1001264b95956773f2bd8bf14ae0ac..f45421ad9e455adab3761bcbb6009a28672ee4c1 100644 (file)
@@ -1170,23 +1170,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):