]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- unit test fixes
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 10 Oct 2009 16:14:13 +0000 (16:14 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 10 Oct 2009 16:14:13 +0000 (16:14 +0000)
- py3k readme
- removed column.sequence accessor

CHANGES
README.py3k [new file with mode: 0644]
lib/sqlalchemy/dialects/oracle/cx_oracle.py
lib/sqlalchemy/schema.py
test/engine/test_metadata.py
test/ext/test_declarative.py
test/orm/inheritance/test_query.py
test/orm/test_unitofwork.py
test/sql/test_defaults.py

diff --git a/CHANGES b/CHANGES
index 1c2b913c4df24d7202f479972d3cb3fd0799679b..c52d94d3c37220586b24a3bcac671bbae11c18d5 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -152,7 +152,8 @@ CHANGES
           table.append_constraint(PrimaryKeyConstraint(...))
         - Column.bind       (get via column.table.bind)
         - Column.metadata   (get via column.table.metadata)
-
+        - Column.sequence   (use column.default)
+        
     - The use_alter flag on ForeignKey is now a shortcut option
       for operations that can be hand-constructed using the
       DDL() event system. A side effect of this refactor is
diff --git a/README.py3k b/README.py3k
new file mode 100644 (file)
index 0000000..c43ec68
--- /dev/null
@@ -0,0 +1,39 @@
+=================
+PYTHON 3 SUPPORT
+=================
+
+Current Python 3k support in SQLAlchemy is provided by a customized
+2to3 script which wraps Python's 2to3 tool.
+
+This document will refer to the Python 2.6 interpreter binary as
+"python26" and the Python 3.xx interpreter binary as "python3".
+
+To build the Python 3K version, use the Python 2.6 interpreter to
+run the 2to3 script on the lib/ directory, and optionally the test/
+directory.   The -w flag indicates that the new files should be
+written.
+
+    python26 sa2to3.py ./lib/ ./test/ -w
+
+You now have a Python 3 version of SQLAlchemy in lib/.   
+
+
+Running Tests
+-------------
+
+The unit test runner, described in README.unittests, is built on
+Nose, and uses a plugin that is ordinarily installed using setuptools
+entry points.  At the time of this writing setuptools isn't available 
+for Python 3 although the "Distribute" project does seem to provide support.
+Additionally, Nose itself is only available in an old version for Python 3,
+which is available at http://bitbucket.org/jpellerin/nose3/ .
+
+To run the unit tests using the old version of nose and without the usage of 
+setuptools, use the "sqla_nose.py" script:
+
+    python3 sqla_nose.py
+    
+When running with Python 3, lots of debug output is dumped to the console.
+This is due to hacking around the old version of Nose to support the 
+SQLAlchemy test plugin without setuptools (details at 
+http://groups.google.com/group/nose-dev/browse_thread/thread/c6a25531baaa2531).
\ No newline at end of file
index 721c455884ae7a915709438493468dc5cfff9b41..65f3cb928a38d9c7694e6d3a0efcddfe57e7083b 100644 (file)
@@ -123,9 +123,12 @@ class _OracleTimestamp(sqltypes.TIMESTAMP):
 
 class _LOBMixin(object):
     def result_processor(self, dialect):
-        super_process = super(_LOBMixin, self).result_processor(dialect)
         if not dialect.auto_convert_lobs:
-            return super_process
+            # return the cx_oracle.LOB directly.
+            # don't even call super.result_processor here.
+            return None
+            
+        super_process = super(_LOBMixin, self).result_processor(dialect)
         lob = dialect.dbapi.LOB
         def process(value):
             if isinstance(value, lob):
index dc212ccac35875197da8fd3d2dba5ef865c1202a..b91764da1262ea4980762ad49232ceb9e7aa093d 100644 (file)
@@ -642,7 +642,7 @@ class Column(SchemaItem, expression.ColumnClause):
         self._table_events = set()
         
         if self.default is not None:
-            if isinstance(self.default, ColumnDefault):
+            if isinstance(self.default, (ColumnDefault, Sequence)):
                 args.append(self.default)
             else:
                 args.append(ColumnDefault(self.default))
@@ -1152,7 +1152,7 @@ class Sequence(DefaultGenerator):
 
     def _set_parent(self, column):
         super(Sequence, self)._set_parent(column)
-        column.sequence = self
+#        column.sequence = self
         
         column._on_table_attach(self._set_table)
     
index 2b751db26359a8f06e729b4c098ccadc12bfa9fc..2612f102932b0e8eafe0c84b62801a3228e48719 100644 (file)
@@ -1,8 +1,7 @@
 from sqlalchemy.test.testing import assert_raises, assert_raises_message
 import pickle
-from sqlalchemy import Integer, String, UniqueConstraint, CheckConstraint, ForeignKey, MetaData
-from sqlalchemy.test.schema import Table
-from sqlalchemy.test.schema import Column
+from sqlalchemy import Integer, String, UniqueConstraint, CheckConstraint, ForeignKey, MetaData, Sequence
+from sqlalchemy.test.schema import Table, Column
 from sqlalchemy import schema
 import sqlalchemy as tsa
 from sqlalchemy.test import TestBase, ComparesTables, AssertsCompiledSQL, testing, engines
@@ -38,7 +37,7 @@ class MetaDataTest(TestBase, ComparesTables):
                 assert str(e) == "Table 'table1' is already defined for this MetaData instance.  Specify 'useexisting=True' to redefine options and columns on an existing Table object."
         finally:
             metadata.drop_all()
-
+    
     @testing.exclude('mysql', '<', (4, 1, 1), 'early types are squirrely')
     def test_to_metadata(self):
         meta = MetaData()
@@ -54,7 +53,7 @@ class MetaDataTest(TestBase, ComparesTables):
         )
 
         table2 = Table('othertable', meta,
-            Column('id', Integer, primary_key=True),
+            Column('id', Integer, Sequence('foo_seq'), primary_key=True),
             Column('myid', Integer, ForeignKey('mytable.myid')),
             test_needs_fk=True,
             )
@@ -100,7 +99,8 @@ class MetaDataTest(TestBase, ComparesTables):
                     assert str(table_c.c.foo.server_onupdate.arg) == 'q'
                     assert str(table_c.c.bar.default.arg) == 'y'
                     assert getattr(table_c.c.bar.onupdate.arg, 'arg', table_c.c.bar.onupdate.arg) == 'z'
-                
+                    assert isinstance(table2_c.c.id.default, Sequence)
+                    
                 # constraints dont get reflected for any dialect right now
                 if has_constraints:
                     for c in table_c.c.description.constraints:
index 066ce2a9f7b973a70543b5c833db96321df24d38..6bd45833c7181f0905030a4045e3ff62fe2c9192 100644 (file)
@@ -276,11 +276,11 @@ class DeclarativeTest(DeclarativeTestBase):
         
         class Master(Base): 
             __tablename__ = 'master' 
-            id = Column(Integer, primary_key=True) 
+            id = Column(Integer, primary_key=True, test_needs_autoincrement=True
 
         class Detail(Base): 
             __tablename__ = 'detail' 
-            id = Column(Integer, primary_key=True) 
+            id = Column(Integer, primary_key=True, test_needs_autoincrement=True
             master_id = Column(None, ForeignKey(Master.id)) 
             master = relation(Master) 
 
index c74ddcad6f48d1fe952fb96924bb8ef112f3c55f..bebad14186817d42909bbc48833a8a277f582cc5 100644 (file)
@@ -1190,7 +1190,8 @@ class EagerToSubclassTest(_base.MappedTest):
         sess = create_session()
         def go():
             eq_(
-                sess.query(Parent).join(Parent.children).options(contains_eager(Parent.children)).all(), 
+                sess.query(Parent).join(Parent.children).options(contains_eager(Parent.children)).\
+                                order_by(Parent.data, Sub.data).all(), 
                 [
                     Parent(data='p1', children=[Sub(data='s1'), Sub(data='s2'), Sub(data='s3')]),
                     Parent(data='p2', children=[Sub(data='s4'), Sub(data='s5')])
index b987291ca90936ceda4326428020c5949bd5fa3e..8ff6b1a65776ed09b96bc519f2b97208c4080e53 100644 (file)
@@ -310,7 +310,7 @@ class BinaryHistTest(_base.MappedTest, testing.AssertsExecutionResults):
     @classmethod
     def define_tables(cls, metadata):
         Table('t1', metadata,
-            Column('id', sa.Integer, primary_key=True),
+            Column('id', sa.Integer, primary_key=True, test_needs_autoincrement=True),
             Column('data', sa.Binary),
         )
 
index 95e87ecbf83c0d4e64f3c630d442ece9e0956ed6..baed19f88542f4e866c1d1335801a3d1dc8aa051 100644 (file)
@@ -613,7 +613,7 @@ class SequenceTest(testing.TestBase):
 
     @testing.fails_on('maxdb', 'FIXME: unknown')
     def teststandalone2(self):
-        x = cartitems.c.cart_id.sequence.execute()
+        x = cartitems.c.cart_id.default.execute()
         self.assert_(1 <= x <= 4)
 
     @classmethod