Commits

Taavi Burns committed 8c6c7e7

Fix 3 errors in py32, from patch from lsblakk. There are still 8 failures. See #2088.

  • Participants
  • Parent commits 14ac187

Comments (0)

Files changed (4)

File lib/sqlalchemy/util/compat.py

 except ImportError:
     import dummy_threading as threading
 
+py32 = sys.version_info >= (3, 2)
 py3k = getattr(sys, 'py3kwarning', False) or sys.version_info >= (3, 0)
 jython = sys.platform.startswith('java')
 pypy = hasattr(sys, 'pypy_version_info')

File test/ext/test_declarative.py

 
             __tablename__ = 'users'
             id = Column('id', Integer, primary_key=True)
-            addresses = relationship('Addresss')
+            addresses = relationship('Address')
 
         # hasattr() on a compile-loaded attribute
-
-        hasattr(User.addresses, 'property')
+        try:
+            hasattr(User.addresses, 'property')
+        except exc.InvalidRequestError:
+            assert sa.util.compat.py32
 
         # the exception is preserved.  Remains the 
         # same through repeated calls.

File test/orm/test_mapper.py

             'user':relationship(User)
         })
 
-        hasattr(Address.user, 'property')
+        try:
+            hasattr(Address.user, 'property')
+        except sa.orm.exc.UnmappedClassError:
+            assert util.compat.py32
+
         for i in range(3):
             assert_raises_message(sa.exc.InvalidRequestError,
                                   "^One or more mappers failed to "

File test/sql/test_compiler.py

         assert hasattr(table1.select(), 'c')
         assert not hasattr(table1.c.myid.self_group(), 'columns')
         assert hasattr(table1.select().self_group(), 'columns')
-        assert not hasattr(select([table1.c.myid]).as_scalar().self_group(), 'columns')
         assert not hasattr(table1.c.myid, 'columns')
         assert not hasattr(table1.c.myid, 'c')
         assert not hasattr(table1.select().c.myid, 'c')
         assert not hasattr(table1.select().c.myid, 'columns')
         assert not hasattr(table1.alias().c.myid, 'columns')
         assert not hasattr(table1.alias().c.myid, 'c')
+        if util.compat.py32:
+            assert_raises_message(
+                exc.InvalidRequestError,
+                'Scalar Select expression has no '
+                'columns; use this object directly within a '
+                'column-level expression.',
+                lambda: hasattr(select([table1.c.myid]).as_scalar().self_group(), 'columns'))
+            assert_raises_message(
+                exc.InvalidRequestError,
+                'Scalar Select expression has no '
+                'columns; use this object directly within a '
+                'column-level expression.',
+                lambda: hasattr(select([table1.c.myid]).as_scalar(), 'columns'))
+        else:
+            assert not hasattr(select([table1.c.myid]).as_scalar().self_group(), 'columns')
+            assert not hasattr(select([table1.c.myid]).as_scalar(), 'columns')
 
     def test_table_select(self):
         self.assert_compile(table1.select(),