summaryrefslogtreecommitdiff
path: root/test/engine
diff options
context:
space:
mode:
authorJason Kirtland <jek@discorporate.us>2008-05-09 20:26:09 +0000
committerJason Kirtland <jek@discorporate.us>2008-05-09 20:26:09 +0000
commite41c0f4107a132b2feac83ba07a25a336e7eae0b (patch)
tree09c785fd5ef9557c3fc926afd7e0a78702dd8023 /test/engine
parenta2122a89f6d4f2d3ccc4ba7665cd588c2b0b93b0 (diff)
downloadsqlalchemy-e41c0f4107a132b2feac83ba07a25a336e7eae0b.tar.gz
Test suite modernization in progress. Big changes:
- @unsupported now only accepts a single target and demands a reason for not running the test. - @exclude also demands an exclusion reason - Greatly expanded @testing.requires.<feature>, eliminating many decorators in the suite and signficantly easing integration of multi-driver support. - New ORM test base class, and a featureful base for mapped tests - Usage of 'global' for shared setup going away, * imports as well
Diffstat (limited to 'test/engine')
-rw-r--r--test/engine/_base.py17
-rw-r--r--test/engine/execute.py2
-rw-r--r--test/engine/metadata.py2
-rw-r--r--test/engine/reflection.py41
-rw-r--r--test/engine/transaction.py36
5 files changed, 61 insertions, 37 deletions
diff --git a/test/engine/_base.py b/test/engine/_base.py
new file mode 100644
index 000000000..9ffdb5e1a
--- /dev/null
+++ b/test/engine/_base.py
@@ -0,0 +1,17 @@
+from testlib import testing
+
+
+class AltEngineTest(testing.TestBase):
+ engine = None
+
+ def setUpAll(self):
+ type(self).engine = self.create_engine()
+ testing.TestBase.setUpAll(self)
+
+ def tearDownAll(self):
+ testing.TestBase.tearDownAll(self)
+ self.engine.dispose()
+ type(self).engine = None
+
+ def create_engine(self):
+ raise NotImplementedError
diff --git a/test/engine/execute.py b/test/engine/execute.py
index 36a6bc317..4e75819b4 100644
--- a/test/engine/execute.py
+++ b/test/engine/execute.py
@@ -49,7 +49,7 @@ class ExecuteTest(TestBase):
# pyformat is supported for mysql, but skipping because a few driver
# versions have a bug that bombs out on this test. (1.2.2b3, 1.2.2c1, 1.2.2)
- @testing.unsupported('mysql')
+ @testing.unsupported('mysql', 'supported but not covered for MySQLdb')
@testing.fails_on_everything_except('postgres')
def test_raw_python(self):
for conn in (testing.db, testing.db.connect()):
diff --git a/test/engine/metadata.py b/test/engine/metadata.py
index 90f8a00a8..ec088d7b2 100644
--- a/test/engine/metadata.py
+++ b/test/engine/metadata.py
@@ -38,7 +38,7 @@ class MetaDataTest(TestBase, ComparesTables):
finally:
metadata.drop_all()
- @testing.exclude('mysql', '<', (4, 1, 1))
+ @testing.exclude('mysql', '<', (4, 1, 1), 'early types are squirrely')
def test_to_metadata(self):
meta = MetaData()
diff --git a/test/engine/reflection.py b/test/engine/reflection.py
index 64c8489ed..e4ef21e37 100644
--- a/test/engine/reflection.py
+++ b/test/engine/reflection.py
@@ -10,7 +10,7 @@ metadata, users = None, None
class ReflectionTest(TestBase, ComparesTables):
- @testing.exclude('mysql', '<', (4, 1, 1))
+ @testing.exclude('mysql', '<', (4, 1, 1), 'early types are squirrely')
def test_basic_reflection(self):
meta = MetaData(testing.db)
@@ -239,6 +239,7 @@ class ReflectionTest(TestBase, ComparesTables):
finally:
meta.drop_all()
+ @testing.exclude('mysql', '<', (4, 1, 1), 'innodb funkiness')
def test_override_existing_fk(self):
"""test that you can override columns and specify new foreign keys to other reflected tables,
on columns which *do* already have that foreign key, and that the FK is not duped.
@@ -271,7 +272,7 @@ class ReflectionTest(TestBase, ComparesTables):
assert u2.join(a2).onclause == u2.c.id==a2.c.user_id
meta2 = MetaData(testing.db)
- u2 = Table('users', meta2,
+ u2 = Table('users', meta2,
Column('id', sa.Integer, primary_key=True),
autoload=True)
a2 = Table('addresses', meta2,
@@ -289,6 +290,7 @@ class ReflectionTest(TestBase, ComparesTables):
finally:
meta.drop_all()
+ @testing.exclude('mysql', '<', (4, 1, 1), 'innodb funkiness')
def test_use_existing(self):
meta = MetaData(testing.db)
users = Table('users', meta,
@@ -310,18 +312,18 @@ class ReflectionTest(TestBase, ComparesTables):
assert False
except tsa.exc.InvalidRequestError, err:
assert str(err) == "Table 'users' is already defined for this MetaData instance. Specify 'useexisting=True' to redefine options and columns on an existing Table object."
-
+
users = Table('users', meta2, Column('name', sa.Unicode), autoload=True, useexisting=True)
assert isinstance(users.c.name.type, sa.Unicode)
assert not users.quote
-
+
users = Table('users', meta2, quote=True, autoload=True, useexisting=True)
assert users.quote
-
+
finally:
meta.drop_all()
-
+
def test_pks_not_uniques(self):
"""test that primary key reflection not tripped up by unique indexes"""
@@ -379,7 +381,7 @@ class ReflectionTest(TestBase, ComparesTables):
finally:
testing.db.execute("drop table book")
- @testing.exclude('mysql', '<', (4, 1, 1))
+ @testing.exclude('mysql', '<', (4, 1, 1), 'innodb funkiness')
def test_composite_fk(self):
"""test reflection of composite foreign keys"""
@@ -416,7 +418,7 @@ class ReflectionTest(TestBase, ComparesTables):
meta.drop_all()
- @testing.unsupported('oracle')
+ @testing.unsupported('oracle', 'FIXME: unknown, confirm not fails_on')
def testreserved(self):
# check a table that uses an SQL reserved name doesn't cause an error
meta = MetaData(testing.db)
@@ -572,7 +574,6 @@ class CreateDropTest(TestBase):
finally:
metadata.drop_all(bind=testing.db)
- @testing.exclude('mysql', '<', (4, 1, 1))
def test_createdrop(self):
metadata.create_all(bind=testing.db)
self.assertEqual( testing.db.has_table('items'), True )
@@ -598,19 +599,19 @@ class CreateDropTest(TestBase):
class SchemaManipulationTest(TestBase):
def test_append_constraint_unique(self):
meta = MetaData()
-
+
users = Table('users', meta, Column('id', sa.Integer))
addresses = Table('addresses', meta, Column('id', sa.Integer), Column('user_id', sa.Integer))
-
+
fk = sa.ForeignKeyConstraint(['user_id'],[users.c.id])
-
+
addresses.append_constraint(fk)
addresses.append_constraint(fk)
assert len(addresses.c.user_id.foreign_keys) == 1
assert addresses.constraints == set([addresses.primary_key, fk])
-
-class UnicodeReflectionTest(TestBase):
+class UnicodeReflectionTest(TestBase):
+ @testing.requires.unicode_connections
def test_basic(self):
try:
# the 'convert_unicode' should not get in the way of the reflection
@@ -675,9 +676,10 @@ class SchemaTest(TestBase):
assert buf.index("CREATE TABLE someschema.table1") > -1
assert buf.index("CREATE TABLE someschema.table2") > -1
- @testing.unsupported('sqlite', 'firebird')
+ @testing.unsupported('firebird', 'FIXME: unknown- no schema support in db?')
+ @testing.fails_on('sqlite')
# fixme: revisit these below.
- @testing.fails_on('oracle', 'mssql', 'sybase', 'access')
+ @testing.fails_on('access', 'oracle', 'mssql', 'sybase')
def test_explicit_default_schema(self):
engine = testing.db
@@ -685,6 +687,11 @@ class SchemaTest(TestBase):
schema = testing.db.url.database
elif testing.against('postgres'):
schema = 'public'
+ elif testing.against('sqlite'):
+ # Works for CREATE TABLE main.foo, SELECT FROM main.foo, etc.,
+ # but fails on:
+ # FOREIGN KEY(col2) REFERENCES main.table1 (col1)
+ schema = 'main'
else:
schema = engine.dialect.get_default_schema_name(engine.connect())
@@ -717,7 +724,7 @@ class HasSequenceTest(TestBase):
Column('user_name', sa.String(40)),
)
- @testing.unsupported('sqlite', 'mysql', 'mssql', 'access', 'sybase')
+ @testing.requires.sequences
def test_hassequence(self):
metadata.create_all(bind=testing.db)
self.assertEqual(testing.db.dialect.has_sequence(testing.db, 'user_id_seq'), True)
diff --git a/test/engine/transaction.py b/test/engine/transaction.py
index 1cb6ba7a1..50d38d699 100644
--- a/test/engine/transaction.py
+++ b/test/engine/transaction.py
@@ -69,7 +69,6 @@ class TransactionTest(TestBase):
assert len(result.fetchall()) == 0
connection.close()
- @testing.exclude('mysql', '<', (5, 0, 3))
def test_nested_rollback(self):
connection = testing.db.connect()
@@ -99,7 +98,6 @@ class TransactionTest(TestBase):
connection.close()
- @testing.exclude('mysql', '<', (5, 0, 3))
def test_nesting(self):
connection = testing.db.connect()
transaction = connection.begin()
@@ -117,7 +115,6 @@ class TransactionTest(TestBase):
assert len(result.fetchall()) == 0
connection.close()
- @testing.exclude('mysql', '<', (5, 0, 3))
def test_close(self):
connection = testing.db.connect()
transaction = connection.begin()
@@ -138,7 +135,6 @@ class TransactionTest(TestBase):
assert len(result.fetchall()) == 5
connection.close()
- @testing.exclude('mysql', '<', (5, 0, 3))
def test_close2(self):
connection = testing.db.connect()
transaction = connection.begin()
@@ -343,7 +339,6 @@ class AutoRollbackTest(TestBase):
def tearDownAll(self):
metadata.drop_all(testing.db)
- @testing.unsupported('sqlite')
def test_rollback_deadlock(self):
"""test that returning connections to the pool clears any object locks."""
conn1 = testing.db.connect()
@@ -592,8 +587,6 @@ class TLTransactionTest(TestBase):
finally:
external_connection.close()
- @testing.unsupported('sqlite')
- @testing.exclude('mysql', '<', (5, 0, 3))
def test_nesting(self):
"""tests nesting of transactions"""
external_connection = tlengine.connect()
@@ -612,7 +605,6 @@ class TLTransactionTest(TestBase):
finally:
external_connection.close()
- @testing.exclude('mysql', '<', (5, 0, 3))
def test_mixed_nesting(self):
"""tests nesting of transactions off the TLEngine directly inside of
tranasctions off the connection from the TLEngine"""
@@ -641,7 +633,6 @@ class TLTransactionTest(TestBase):
finally:
external_connection.close()
- @testing.exclude('mysql', '<', (5, 0, 3))
def test_more_mixed_nesting(self):
"""tests nesting of transactions off the connection from the TLEngine
inside of tranasctions off thbe TLEngine directly."""
@@ -665,8 +656,6 @@ class TLTransactionTest(TestBase):
finally:
external_connection.close()
-
-
def test_connections(self):
"""tests that contextual_connect is threadlocal"""
c1 = tlengine.contextual_connect()
@@ -743,15 +732,18 @@ class ForUpdateTest(TestBase):
break
con.close()
- @testing.unsupported('sqlite', 'mssql', 'firebird', 'sybase', 'access')
-
+ @testing.unsupported('sqlite', 'needs n threads -> 1 :memory: db')
+ @testing.unsupported('mssql', 'FIXME: unknown')
+ @testing.unsupported('firebird', 'FIXME: unknown')
+ @testing.unsupported('sybase', 'FIXME: unknown')
+ @testing.unsupported('access', 'FIXME: unknown')
def test_queued_update(self):
"""Test SELECT FOR UPDATE with concurrent modifications.
Runs concurrent modifications on a single row in the users table,
with each mutator trying to increment a value stored in user_name.
- """
+ """
db = testing.db
db.execute(counters.insert(), counter_id=1, counter_value=0)
@@ -768,7 +760,7 @@ class ForUpdateTest(TestBase):
thread.join()
for e in errors:
- sys.stderr.write("Failure: %s\n" % e)
+ sys.stdout.write("Failure: %s\n" % e)
self.assert_(len(errors) == 0)
@@ -806,7 +798,11 @@ class ForUpdateTest(TestBase):
return errors
- @testing.unsupported('sqlite', 'mssql', 'firebird', 'sybase', 'access')
+ @testing.unsupported('sqlite', 'needs n threads -> 1 memory db')
+ @testing.unsupported('mssql', 'FIXME: unknown')
+ @testing.unsupported('firebird', 'FIXME: unknown')
+ @testing.unsupported('sybase', 'FIXME: unknown')
+ @testing.unsupported('access', 'FIXME: unknown')
def test_queued_select(self):
"""Simple SELECT FOR UPDATE conflict test"""
@@ -815,8 +811,12 @@ class ForUpdateTest(TestBase):
sys.stderr.write("Failure: %s\n" % e)
self.assert_(len(errors) == 0)
- @testing.unsupported('sqlite', 'mysql', 'mssql', 'firebird',
- 'sybase', 'access')
+ @testing.unsupported('sqlite', 'needs n threads -> 1 memory db')
+ @testing.unsupported('mssql', 'FIXME: unknown')
+ @testing.unsupported('mysql', 'no support for NOWAIT')
+ @testing.unsupported('firebird', 'FIXME: unknown')
+ @testing.unsupported('sybase', 'FIXME: unknown')
+ @testing.unsupported('access', 'FIXME: unknown')
def test_nowait_select(self):
"""Simple SELECT FOR UPDATE NOWAIT conflict test"""