]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fix 3 errors in py32, from patch from lsblakk. There are still 8 failures. See #2088.
authorTaavi Burns <taavi.burns@gmail.com>
Wed, 16 Mar 2011 04:32:33 +0000 (00:32 -0400)
committerTaavi Burns <taavi.burns@gmail.com>
Wed, 16 Mar 2011 04:32:33 +0000 (00:32 -0400)
lib/sqlalchemy/util/compat.py
test/ext/test_declarative.py
test/orm/test_mapper.py
test/sql/test_compiler.py

index 5aea70f242966941ad0902dd2e54c1359ac54ccf..0fb004500878517a7fe5bb73e3a762b3d754c9fb 100644 (file)
@@ -17,6 +17,7 @@ try:
 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')
index 50b8fe85193396b40ded9841a7cad49bd1b60edb..91055911c6ddc437010d760841ca37ca1fd57e6c 100644 (file)
@@ -419,11 +419,13 @@ class DeclarativeTest(DeclarativeTestBase):
 
             __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.
index abef6ed18676af96d4a779631782ed47d94e0b3d..e26097116c6748414806b90731dfc524f360fcef 100644 (file)
@@ -112,7 +112,11 @@ class MapperTest(_fixtures.FixtureTest):
             '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 "
index b060fef5b00ca0303d1c55a4a9cae04e23637198..69765a4fa62bb4bd4ac762266062deda0d4eda12 100644 (file)
@@ -69,13 +69,28 @@ class SelectTest(TestBase, AssertsCompiledSQL):
         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(),