]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
some test fixes and cleanup
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 16 Jul 2012 21:37:32 +0000 (17:37 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 16 Jul 2012 21:37:32 +0000 (17:37 -0400)
lib/sqlalchemy/orm/util.py
test/aaa_profiling/test_orm.py
test/orm/test_inspect.py

index 03af1ad766e2ab220b7b1771b2b3986f5a5fde57..e9e11ee875d2e0d16ee8f7ce058be8d9ac02ed63 100644 (file)
@@ -93,7 +93,8 @@ def _validator_events(desc, key, validator, include_removes):
     if include_removes:
         event.listen(desc, "remove", remove, raw=True, retval=True)
 
-def polymorphic_union(table_map, typecolname, aliasname='p_union', cast_nulls=True):
+def polymorphic_union(table_map, typecolname,
+                        aliasname='p_union', cast_nulls=True):
     """Create a ``UNION`` statement used by a polymorphic mapper.
 
     See  :ref:`concrete_inheritance` for an example of how
@@ -102,13 +103,14 @@ def polymorphic_union(table_map, typecolname, aliasname='p_union', cast_nulls=Tr
     :param table_map: mapping of polymorphic identities to
      :class:`.Table` objects.
     :param typecolname: string name of a "discriminator" column, which will be
-     derived from the query, producing the polymorphic identity for each row.  If
-     ``None``, no polymorphic discriminator is generated.
+     derived from the query, producing the polymorphic identity for
+     each row.  If ``None``, no polymorphic discriminator is generated.
     :param aliasname: name of the :func:`~sqlalchemy.sql.expression.alias()`
      construct generated.
-    :param cast_nulls: if True, non-existent columns, which are represented as labeled
-     NULLs, will be passed into CAST.   This is a legacy behavior that is problematic
-     on some backends such as Oracle - in which case it can be set to False.
+    :param cast_nulls: if True, non-existent columns, which are represented
+     as labeled NULLs, will be passed into CAST.   This is a legacy behavior
+     that is problematic on some backends such as Oracle - in which case it
+     can be set to False.
 
     """
 
@@ -312,7 +314,7 @@ class PathRegistry(object):
 
     @classmethod
     def coerce(cls, raw):
-        return util.reduce(lambda prev, next:prev[next], raw, cls.root)
+        return util.reduce(lambda prev, next: prev[next], raw, cls.root)
 
     @classmethod
     def token(cls, token):
@@ -320,7 +322,7 @@ class PathRegistry(object):
 
     def __add__(self, other):
         return util.reduce(
-                    lambda prev, next:prev[next],
+                    lambda prev, next: prev[next],
                     other.path, self)
 
     def __repr__(self):
index d66d2704ddb3816a964dc2e477e4050dd155a3b5..4295f51e4d6196e385f6efbbda8b7d7a2f02abc3 100644 (file)
@@ -62,7 +62,7 @@ class MergeTest(fixtures.MappedTest):
         # bigger operation so using a small variance
 
         @profiling.function_call_count(variance=0.05,
-                versions={'2.7':93, '2.6':93, '2.5':94, '3': 100})
+                versions={'2.7':96, '2.6':96, '2.5':96, '3': 100})
         def go():
             return sess2.merge(p1, load=False)
         p2 = go()
@@ -70,7 +70,7 @@ class MergeTest(fixtures.MappedTest):
         # third call, merge object already present. almost no calls.
 
         @profiling.function_call_count(variance=0.05,
-                versions={'2.7':15, '2.6':15, '2.5':16, '3': 16})
+                versions={'2.7':16, '2.6':16, '2.5':16, '3': 16})
         def go():
             return sess2.merge(p2, load=False)
         p3 = go()
@@ -90,7 +90,7 @@ class MergeTest(fixtures.MappedTest):
 
         @profiling.function_call_count(variance=0.10,
                                 versions={'2.5':1050, '2.6':1050,
-                                        '2.6+cextension':1014, 
+                                        '2.6+cextension':1014,
                                         '2.7':1014,
                                         '3':1050}
                             )
@@ -106,14 +106,14 @@ class MergeTest(fixtures.MappedTest):
 class LoadManyToOneFromIdentityTest(fixtures.MappedTest):
     """test overhead associated with many-to-one fetches.
 
-    Prior to the refactor of LoadLazyAttribute and 
+    Prior to the refactor of LoadLazyAttribute and
     query._get(), the load from identity map took 2x
     as many calls (65K calls here instead of around 33K)
     to load 1000 related objects from the identity map.
 
     """
 
-    # only need to test for unexpected variance in a large call 
+    # only need to test for unexpected variance in a large call
     # count here,
     # so remove some platforms that have wildly divergent
     # callcounts.
@@ -122,13 +122,13 @@ class LoadManyToOneFromIdentityTest(fixtures.MappedTest):
 
     @classmethod
     def define_tables(cls, metadata):
-        parent = Table('parent', metadata, 
-                        Column('id', Integer, primary_key=True), 
+        parent = Table('parent', metadata,
+                        Column('id', Integer, primary_key=True),
                        Column('data', String(20)),
                        Column('child_id', Integer, ForeignKey('child.id'))
                        )
 
-        child = Table('child', metadata, 
+        child = Table('child', metadata,
                     Column('id', Integer,primary_key=True),
                   Column('data', String(20))
                  )
@@ -162,10 +162,10 @@ class LoadManyToOneFromIdentityTest(fixtures.MappedTest):
         ])
         parent.insert().execute([
             {
-                'id':i, 
-                'data':'p%dc%d' % (i, (i % 250) + 1), 
+                'id':i,
+                'data':'p%dc%d' % (i, (i % 250) + 1),
                 'child_id':(i % 250) + 1
-            } 
+            }
             for i in xrange(1, 1000)
         ])
 
@@ -201,18 +201,18 @@ class MergeBackrefsTest(fixtures.MappedTest):
     @classmethod
     def define_tables(cls, metadata):
         Table('a', metadata,
-            Column('id', Integer, primary_key=True), 
+            Column('id', Integer, primary_key=True),
             Column('c_id', Integer, ForeignKey('c.id'))
         )
         Table('b', metadata,
-            Column('id', Integer, primary_key=True), 
+            Column('id', Integer, primary_key=True),
             Column('a_id', Integer, ForeignKey('a.id'))
         )
         Table('c', metadata,
-            Column('id', Integer, primary_key=True), 
+            Column('id', Integer, primary_key=True),
         )
         Table('d', metadata,
-            Column('id', Integer, primary_key=True), 
+            Column('id', Integer, primary_key=True),
             Column('a_id', Integer, ForeignKey('a.id'))
         )
 
@@ -248,7 +248,7 @@ class MergeBackrefsTest(fixtures.MappedTest):
                     cls.classes.C, cls.classes.D
         s = Session()
         s.add_all([
-            A(id=i, 
+            A(id=i,
                 bs=[B(id=(i * 50) + j) for j in xrange(1, 50)],
                 c=C(id=i),
                 ds=[D(id=(i * 50) + j) for j in xrange(1, 50)]
@@ -263,7 +263,7 @@ class MergeBackrefsTest(fixtures.MappedTest):
                     self.classes.C, self.classes.D
         s = Session()
         for a in [
-            A(id=i, 
+            A(id=i,
                 bs=[B(id=(i * 50) + j) for j in xrange(1, 50)],
                 c=C(id=i),
                 ds=[D(id=(i * 50) + j) for j in xrange(1, 50)]
index 128539e68cbf2ed5119d44ebaf7c177c9fd2a13e..4ee01ac62f8a61a4b7ee1250de85cb3ca950cdc5 100644 (file)
@@ -67,7 +67,7 @@ class TestORMInspection(_fixtures.FixtureTest):
         ualias = aliased(Address)
         insp = inspect(ualias)
         is_(insp.mapper, inspect(Address))
-        is_(insp.selectable, ualias._AliasedClass__alias)
+        is_(insp.selectable, ualias._AliasedClass__adapter.selectable)
         assert not insp.is_selectable
         assert insp.is_aliased_class