diff options
67 files changed, 169 insertions, 170 deletions
diff --git a/test/base/dependency.py b/test/base/dependency.py index 56767dc84..25d34ffd3 100644 --- a/test/base/dependency.py +++ b/test/base/dependency.py @@ -4,7 +4,7 @@ from sqlalchemy import util from testlib import * -class DependencySortTest(PersistTest): +class DependencySortTest(TestBase): def assert_sort(self, tuples, node, collection=None): print str(node) def assert_tuple(tuple, node): diff --git a/test/base/utils.py b/test/base/utils.py index 9d6526379..6ab141d6c 100644 --- a/test/base/utils.py +++ b/test/base/utils.py @@ -4,7 +4,7 @@ from sqlalchemy import util, sql, exceptions from testlib import * from testlib import sorted -class OrderedDictTest(PersistTest): +class OrderedDictTest(TestBase): def test_odict(self): o = util.OrderedDict() o['a'] = 1 @@ -35,7 +35,7 @@ class OrderedDictTest(PersistTest): self.assert_(o.keys() == ['a', 'b', 'c', 'd', 'e', 'f']) self.assert_(o.values() == [1, 2, 3, 4, 5, 6]) -class OrderedSetTest(PersistTest): +class OrderedSetTest(TestBase): def test_mutators_against_iter(self): # testing a set modified against an iterator o = util.OrderedSet([3,2, 4, 5]) @@ -47,7 +47,7 @@ class OrderedSetTest(PersistTest): self.assertEquals(o.union(iter([3,4, 6])), util.OrderedSet([2, 3, 4, 5, 6])) -class ColumnCollectionTest(PersistTest): +class ColumnCollectionTest(TestBase): def test_in(self): cc = sql.ColumnCollection() cc.add(sql.column('col1')) @@ -322,7 +322,7 @@ class DictlikeIteritemsTest(unittest.TestCase): self._notok(duck6()) -class ArgInspectionTest(PersistTest): +class ArgInspectionTest(TestBase): def test_get_cls_kwargs(self): class A(object): def __init__(self, a): diff --git a/test/dialect/access.py b/test/dialect/access.py index 52a72e66a..311231947 100644 --- a/test/dialect/access.py +++ b/test/dialect/access.py @@ -4,7 +4,7 @@ from sqlalchemy.databases import access from testlib import * -class BasicTest(AssertMixin): +class BasicTest(TestBase, AssertsExecutionResults): # A simple import of the database/ module should work on all systems. def test_import(self): # we got this far, right? diff --git a/test/dialect/firebird.py b/test/dialect/firebird.py index e327bf151..fe4161a1b 100644 --- a/test/dialect/firebird.py +++ b/test/dialect/firebird.py @@ -6,7 +6,7 @@ from sqlalchemy.sql import table, column from testlib import * -class DomainReflectionTest(AssertMixin): +class DomainReflectionTest(TestBase, AssertsExecutionResults): "Test Firebird domains" __only_on__ = 'firebird' @@ -68,7 +68,7 @@ class DomainReflectionTest(AssertMixin): self.assertEquals(table.c.dt.type.__class__, firebird.FBDateTime) -class CompileTest(SQLCompileTest): +class CompileTest(TestBase, AssertsCompiledSQL): __dialect__ = firebird.FBDialect() def test_alias(self): @@ -86,7 +86,7 @@ class CompileTest(SQLCompileTest): self.assert_compile(select([func.max(t.c.col1)]), "SELECT max(sometable.col1) AS max_1 FROM sometable") -class MiscFBTests(PersistTest): +class MiscFBTests(TestBase): __only_on__ = 'firebird' diff --git a/test/dialect/informix.py b/test/dialect/informix.py index da518075b..4a2546f17 100644 --- a/test/dialect/informix.py +++ b/test/dialect/informix.py @@ -4,7 +4,7 @@ from sqlalchemy.databases import informix from testlib import * -class BasicTest(AssertMixin): +class BasicTest(TestBase, AssertsExecutionResults): # A simple import of the database/ module should work on all systems. def test_import(self): # we got this far, right? diff --git a/test/dialect/maxdb.py b/test/dialect/maxdb.py index 4ec9faa6c..0a35f5470 100644 --- a/test/dialect/maxdb.py +++ b/test/dialect/maxdb.py @@ -15,7 +15,7 @@ from testlib import * # - datetime tests # - the orm/query 'test_has' destabilizes the server- cover here -class ReflectionTest(AssertMixin): +class ReflectionTest(TestBase, AssertsExecutionResults): """Extra reflection tests.""" __only_on__ = 'maxdb' @@ -168,7 +168,7 @@ class ReflectionTest(AssertMixin): except exceptions.DatabaseError: pass -class DBAPITest(AssertMixin): +class DBAPITest(TestBase, AssertsExecutionResults): """Asserts quirks in the native Python DB-API driver. If any of these fail, that's good- the bug is fixed! diff --git a/test/dialect/mssql.py b/test/dialect/mssql.py index 5a7707052..c5ba62718 100755 --- a/test/dialect/mssql.py +++ b/test/dialect/mssql.py @@ -8,7 +8,7 @@ from sqlalchemy.databases import mssql from testlib import * -class CompileTest(SQLCompileTest): +class CompileTest(TestBase, AssertsCompiledSQL): __dialect__ = mssql.MSSQLDialect() def test_insert(self): @@ -94,7 +94,7 @@ class CompileTest(SQLCompileTest): t = Table('sometable', m, Column('col1', Integer), Column('col2', Integer)) self.assert_compile(select([func.max(t.c.col1)]), "SELECT max(sometable.col1) AS max_1 FROM sometable") -class ReflectionTest(PersistTest): +class ReflectionTest(TestBase): __only_on__ = 'mssql' def testidentity(self): @@ -114,7 +114,7 @@ class ReflectionTest(PersistTest): table.drop() -class QueryTest(PersistTest): +class QueryTest(TestBase): __only_on__ = 'mssql' def test_fetchid_trigger(self): @@ -209,7 +209,7 @@ class Foo(object): for k in kw: setattr(self, k, kw[k]) -class GenerativeQueryTest(PersistTest): +class GenerativeQueryTest(TestBase): __only_on__ = 'mssql' def setUpAll(self): diff --git a/test/dialect/mysql.py b/test/dialect/mysql.py index 2b589f625..e1bd47d29 100644 --- a/test/dialect/mysql.py +++ b/test/dialect/mysql.py @@ -6,7 +6,7 @@ from sqlalchemy.databases import mysql from testlib import * -class TypesTest(AssertMixin): +class TypesTest(TestBase, AssertsExecutionResults): "Test MySQL column types" __only_on__ = 'mysql' @@ -762,7 +762,7 @@ class TypesTest(AssertMixin): self.assertEqual(got, wanted) -class SQLTest(SQLCompileTest): +class SQLTest(TestBase, AssertsCompiledSQL): """Tests MySQL-dialect specific compilation.""" __dialect__ = mysql.dialect() diff --git a/test/dialect/oracle.py b/test/dialect/oracle.py index 9436d1915..cb4ead18c 100644 --- a/test/dialect/oracle.py +++ b/test/dialect/oracle.py @@ -5,7 +5,7 @@ from sqlalchemy.databases import oracle from testlib import * -class OutParamTest(AssertMixin): +class OutParamTest(TestBase, AssertsExecutionResults): __only_on__ = 'oracle' def setUpAll(self): @@ -28,7 +28,7 @@ create or replace procedure foo(x_in IN number, x_out OUT number, y_out OUT numb testing.db.execute("DROP PROCEDURE foo") -class CompileTest(SQLCompileTest): +class CompileTest(TestBase, AssertsCompiledSQL): __dialect__ = oracle.OracleDialect() def test_subquery(self): @@ -135,7 +135,7 @@ myothertable.othername != :myothertable_othername_1 OR EXISTS (select yay from f "ON addresses.address_type_id = address_types_1.id WHERE addresses.user_id = :addresses_user_id_1 ORDER BY addresses.rowid, " "address_types.rowid") -class TypesTest(SQLCompileTest): +class TypesTest(TestBase, AssertsCompiledSQL): __only_on__ = 'oracle' def test_no_clobs_for_string_params(self): @@ -181,7 +181,7 @@ class TypesTest(SQLCompileTest): finally: testing.db.execute("DROP TABLE Z_TEST") -class SequenceTest(SQLCompileTest): +class SequenceTest(TestBase, AssertsCompiledSQL): def test_basic(self): seq = Sequence("my_seq_no_schema") dialect = oracle.OracleDialect() diff --git a/test/dialect/postgres.py b/test/dialect/postgres.py index 760affe8f..9ec44203a 100644 --- a/test/dialect/postgres.py +++ b/test/dialect/postgres.py @@ -8,7 +8,7 @@ from testlib import * from sqlalchemy.sql import table, column -class SequenceTest(SQLCompileTest): +class SequenceTest(TestBase, AssertsCompiledSQL): def test_basic(self): seq = Sequence("my_seq_no_schema") dialect = postgres.PGDialect() @@ -20,7 +20,7 @@ class SequenceTest(SQLCompileTest): seq = Sequence("My_Seq", schema="Some_Schema") assert dialect.identifier_preparer.format_sequence(seq) == '"Some_Schema"."My_Seq"' -class CompileTest(SQLCompileTest): +class CompileTest(TestBase, AssertsCompiledSQL): def test_update_returning(self): dialect = postgres.dialect() table1 = table('mytable', @@ -57,7 +57,7 @@ class CompileTest(SQLCompileTest): i = insert(table1, values=dict(name='foo'), postgres_returning=[func.length(table1.c.name)]) self.assert_compile(i, "INSERT INTO mytable (name) VALUES (%(name)s) RETURNING length(mytable.name)", dialect=dialect) -class ReturningTest(AssertMixin): +class ReturningTest(TestBase, AssertsExecutionResults): __only_on__ = 'postgres' @testing.exclude('postgres', '<', (8, 2)) @@ -109,7 +109,7 @@ class ReturningTest(AssertMixin): table.drop() -class InsertTest(AssertMixin): +class InsertTest(TestBase, AssertsExecutionResults): __only_on__ = 'postgres' def setUpAll(self): @@ -376,7 +376,7 @@ class InsertTest(AssertMixin): (33, 'd4'), ] -class DomainReflectionTest(AssertMixin): +class DomainReflectionTest(TestBase, AssertsExecutionResults): "Test PostgreSQL domains" __only_on__ = 'postgres' @@ -431,7 +431,7 @@ class DomainReflectionTest(AssertMixin): self.assertEquals(str(table.columns.answer.default.arg), '0', "Reflected default value didn't equal expected value") self.assertTrue(table.columns.answer.nullable, "Expected reflected column to be nullable.") -class MiscTest(AssertMixin): +class MiscTest(TestBase, AssertsExecutionResults): __only_on__ = 'postgres' def test_date_reflection(self): @@ -605,7 +605,7 @@ class MiscTest(AssertMixin): assert executed_sql == ['CREATE INDEX test_idx1 ON testtbl (data) WHERE testtbl.data > 5 AND testtbl.data < 10'] -class TimezoneTest(AssertMixin): +class TimezoneTest(TestBase, AssertsExecutionResults): """Test timezone-aware datetimes. psycopg will return a datetime with a tzinfo attached to it, if postgres @@ -649,7 +649,7 @@ class TimezoneTest(AssertMixin): c = notztable.update(notztable.c.id==1).execute(name='newname') print notztable.select(tztable.c.id==1).execute().fetchone() -class ArrayTest(AssertMixin): +class ArrayTest(TestBase, AssertsExecutionResults): __only_on__ = 'postgres' def setUpAll(self): diff --git a/test/dialect/sqlite.py b/test/dialect/sqlite.py index 70658330f..585a853d2 100644 --- a/test/dialect/sqlite.py +++ b/test/dialect/sqlite.py @@ -8,7 +8,7 @@ from sqlalchemy.databases import sqlite from testlib import * -class TestTypes(AssertMixin): +class TestTypes(TestBase, AssertsExecutionResults): __only_on__ = 'sqlite' def test_date(self): @@ -100,7 +100,7 @@ class TestTypes(AssertMixin): finally: m.drop_all() -class DialectTest(AssertMixin): +class DialectTest(TestBase, AssertsExecutionResults): __only_on__ = 'sqlite' def test_extra_reserved_words(self): @@ -216,7 +216,7 @@ class DialectTest(AssertMixin): pass raise -class InsertTest(AssertMixin): +class InsertTest(TestBase, AssertsExecutionResults): """Tests inserts and autoincrement.""" __only_on__ = 'sqlite' diff --git a/test/dialect/sybase.py b/test/dialect/sybase.py index cdc8066b4..19cca465b 100644 --- a/test/dialect/sybase.py +++ b/test/dialect/sybase.py @@ -4,7 +4,7 @@ from sqlalchemy.databases import sybase from testlib import * -class BasicTest(AssertMixin): +class BasicTest(TestBase, AssertsExecutionResults): # A simple import of the database/ module should work on all systems. def test_import(self): # we got this far, right? diff --git a/test/engine/bind.py b/test/engine/bind.py index c273bdb05..db4955375 100644 --- a/test/engine/bind.py +++ b/test/engine/bind.py @@ -7,7 +7,7 @@ from sqlalchemy import engine, exceptions from testlib import * -class BindTest(PersistTest): +class BindTest(TestBase): def test_create_drop_explicit(self): metadata = MetaData() table = Table('test_table', metadata, diff --git a/test/engine/ddlevents.py b/test/engine/ddlevents.py index e902ec709..3a1f342b4 100644 --- a/test/engine/ddlevents.py +++ b/test/engine/ddlevents.py @@ -5,7 +5,7 @@ import sqlalchemy from testlib import * -class DDLEventTest(PersistTest): +class DDLEventTest(TestBase): class Canary(object): def __init__(self, schema_item, bind): self.state = None @@ -189,7 +189,7 @@ class DDLEventTest(PersistTest): self.assertRaises(LookupError, metadata.append_ddl_listener, 'blah', fn) -class DDLExecutionTest(PersistTest): +class DDLExecutionTest(TestBase): def mock_engine(self): buffer = [] def executor(sql, *a, **kw): @@ -288,7 +288,7 @@ class DDLExecutionTest(PersistTest): r = eval(py) assert list(r) == [(1,)], py -class DDLTest(PersistTest): +class DDLTest(TestBase): def mock_engine(self): executor = lambda *a, **kw: None engine = create_engine(testing.db.name + '://', diff --git a/test/engine/execute.py b/test/engine/execute.py index 220239fbe..643a22a18 100644 --- a/test/engine/execute.py +++ b/test/engine/execute.py @@ -3,7 +3,7 @@ from sqlalchemy import * from sqlalchemy import exceptions from testlib import * -class ExecuteTest(PersistTest): +class ExecuteTest(TestBase): def setUpAll(self): global users, metadata metadata = MetaData(testing.db) diff --git a/test/engine/metadata.py b/test/engine/metadata.py index dd4ee51d3..e93eb69a5 100644 --- a/test/engine/metadata.py +++ b/test/engine/metadata.py @@ -4,7 +4,7 @@ from sqlalchemy import exceptions from testlib import * import pickle -class MetaDataTest(PersistTest, ComparesTables): +class MetaDataTest(TestBase, ComparesTables): def test_metadata_connect(self): metadata = MetaData() t1 = Table('table1', metadata, Column('col1', Integer, primary_key=True), diff --git a/test/engine/parseconnect.py b/test/engine/parseconnect.py index df7ab711b..117c3ed4b 100644 --- a/test/engine/parseconnect.py +++ b/test/engine/parseconnect.py @@ -6,7 +6,7 @@ import sqlalchemy.engine.url as url from testlib import * -class ParseConnectTest(PersistTest): +class ParseConnectTest(TestBase): def test_rfc1738(self): for text in ( 'dbtype://username:password@hostspec:110//usr/db_file.db', @@ -37,7 +37,7 @@ class ParseConnectTest(PersistTest): assert u.host == 'hostspec' or u.host == '127.0.0.1' or (not u.host) assert str(u) == text -class CreateEngineTest(PersistTest): +class CreateEngineTest(TestBase): """test that create_engine arguments of different types get propigated properly""" def test_connect_query(self): dbapi = MockDBAPI(foober='12', lala='18', fooz='somevalue') diff --git a/test/engine/pool.py b/test/engine/pool.py index eb426f029..8e0abb691 100644 --- a/test/engine/pool.py +++ b/test/engine/pool.py @@ -33,7 +33,7 @@ class MockCursor(object): pass mock_dbapi = MockDBAPI() -class PoolTest(PersistTest): +class PoolTest(TestBase): def setUp(self): pool.clear_managers() diff --git a/test/engine/reconnect.py b/test/engine/reconnect.py index 2a18fca2c..1b9962523 100644 --- a/test/engine/reconnect.py +++ b/test/engine/reconnect.py @@ -43,7 +43,7 @@ class MockCursor(object): def close(self): pass -class MockReconnectTest(PersistTest): +class MockReconnectTest(TestBase): def setUp(self): global db, dbapi dbapi = MockDBAPI() @@ -169,7 +169,7 @@ class MockReconnectTest(PersistTest): assert len(dbapi.connections) == 1 -class RealReconnectTest(PersistTest): +class RealReconnectTest(TestBase): def setUp(self): global engine engine = engines.reconnecting_engine() diff --git a/test/engine/reflection.py b/test/engine/reflection.py index 3aa6630eb..127a46a1d 100644 --- a/test/engine/reflection.py +++ b/test/engine/reflection.py @@ -7,7 +7,7 @@ from testlib import * from testlib import engines -class ReflectionTest(PersistTest, ComparesTables): +class ReflectionTest(TestBase, ComparesTables): @testing.exclude('mysql', '<', (4, 1, 1)) def test_basic_reflection(self): @@ -517,7 +517,7 @@ class ReflectionTest(PersistTest, ComparesTables): self.assert_(not m9.tables) -class CreateDropTest(PersistTest): +class CreateDropTest(TestBase): def setUpAll(self): global metadata, users metadata = MetaData() @@ -587,7 +587,7 @@ class CreateDropTest(PersistTest): self.assert_(not Set(metadata.tables) - Set(testing.db.table_names())) metadata.drop_all(bind=testing.db) -class SchemaManipulationTest(PersistTest): +class SchemaManipulationTest(TestBase): def test_append_constraint_unique(self): meta = MetaData() @@ -601,7 +601,7 @@ class SchemaManipulationTest(PersistTest): assert len(addresses.c.user_id.foreign_keys) == 1 assert addresses.constraints == set([addresses.primary_key, fk]) -class UnicodeReflectionTest(PersistTest): +class UnicodeReflectionTest(TestBase): def test_basic(self): try: @@ -638,7 +638,7 @@ class UnicodeReflectionTest(PersistTest): bind.dispose() -class SchemaTest(PersistTest): +class SchemaTest(TestBase): def test_iteration(self): metadata = MetaData() @@ -700,7 +700,7 @@ class SchemaTest(PersistTest): metadata.drop_all() -class HasSequenceTest(PersistTest): +class HasSequenceTest(TestBase): def setUpAll(self): global metadata, users metadata = MetaData() diff --git a/test/engine/transaction.py b/test/engine/transaction.py index 686c640fd..b40970371 100644 --- a/test/engine/transaction.py +++ b/test/engine/transaction.py @@ -6,7 +6,7 @@ from sqlalchemy.orm import * from testlib import * -class TransactionTest(PersistTest): +class TransactionTest(TestBase): def setUpAll(self): global users, metadata metadata = MetaData() @@ -346,7 +346,7 @@ class TransactionTest(PersistTest): conn.close() -class AutoRollbackTest(PersistTest): +class AutoRollbackTest(TestBase): def setUpAll(self): global metadata metadata = MetaData() @@ -375,7 +375,7 @@ class AutoRollbackTest(PersistTest): users.drop(conn2) conn2.close() -class ExplicitAutoCommitTest(PersistTest): +class ExplicitAutoCommitTest(TestBase): """test the 'autocommit' flag on select() and text() objects. Requires Postgres so that we may define a custom function which modifies the database. @@ -450,7 +450,7 @@ class ExplicitAutoCommitTest(PersistTest): conn2.close() -class TLTransactionTest(PersistTest): +class TLTransactionTest(TestBase): def setUpAll(self): global users, metadata, tlengine tlengine = create_engine(testing.db.url, strategy='threadlocal') @@ -700,7 +700,7 @@ class TLTransactionTest(PersistTest): assert c1.connection.connection is not None -class ForUpdateTest(PersistTest): +class ForUpdateTest(TestBase): def setUpAll(self): global counters, metadata metadata = MetaData() diff --git a/test/ext/activemapper.py b/test/ext/activemapper.py index 39e900e38..fa112c3b3 100644 --- a/test/ext/activemapper.py +++ b/test/ext/activemapper.py @@ -10,7 +10,7 @@ import sqlalchemy from testlib import * -class testcase(PersistTest): +class testcase(TestBase): def setUpAll(self): clear_mappers() objectstore.clear() @@ -263,7 +263,7 @@ class testcase(PersistTest): self.assertEquals(Person.query.count(), 2) -class testmanytomany(PersistTest): +class testmanytomany(TestBase): def setUpAll(self): clear_mappers() objectstore.clear() @@ -318,7 +318,7 @@ class testmanytomany(PersistTest): foo1.bazrel.append(baz1) assert (foo1.bazrel == [baz1]) -class testselfreferential(PersistTest): +class testselfreferential(TestBase): def setUpAll(self): clear_mappers() objectstore.clear() diff --git a/test/ext/assignmapper.py b/test/ext/assignmapper.py index 188e4bdbb..1cb2ca375 100644 --- a/test/ext/assignmapper.py +++ b/test/ext/assignmapper.py @@ -7,7 +7,7 @@ from sqlalchemy.ext.sessioncontext import SessionContext from testlib import * -class AssignMapperTest(PersistTest): +class AssignMapperTest(TestBase): def setUpAll(self): global metadata, table, table2 metadata = MetaData(testing.db) diff --git a/test/ext/associationproxy.py b/test/ext/associationproxy.py index 1ebf07cb3..c4c2091ed 100644 --- a/test/ext/associationproxy.py +++ b/test/ext/associationproxy.py @@ -33,7 +33,7 @@ class ObjectCollection(object): def __iter__(self): return iter(self.values) -class _CollectionOperations(PersistTest): +class _CollectionOperations(TestBase): def setUp(self): collection_class = self.collection_class @@ -591,7 +591,7 @@ class CustomObjectTest(_CollectionOperations): except TypeError: pass -class ScalarTest(PersistTest): +class ScalarTest(TestBase): def test_scalar_proxy(self): metadata = MetaData(testing.db) @@ -708,7 +708,7 @@ class ScalarTest(PersistTest): p2.bar = 'quux' -class LazyLoadTest(PersistTest): +class LazyLoadTest(TestBase): def setUp(self): metadata = MetaData(testing.db) diff --git a/test/ext/orderinglist.py b/test/ext/orderinglist.py index ae1bd9450..ff27a6375 100644 --- a/test/ext/orderinglist.py +++ b/test/ext/orderinglist.py @@ -37,7 +37,7 @@ def alpha_ordering(index, collection): s += chr(index + 65) return s -class OrderingListTest(PersistTest): +class OrderingListTest(TestBase): def setUp(self): global metadata, slides_table, bullets_table, Slide, Bullet slides_table, bullets_table = None, None diff --git a/test/orm/association.py b/test/orm/association.py index 4d58f43ce..65d702538 100644 --- a/test/orm/association.py +++ b/test/orm/association.py @@ -4,7 +4,7 @@ from sqlalchemy import * from sqlalchemy.orm import * from testlib import * -class AssociationTest(PersistTest): +class AssociationTest(TestBase): @testing.uses_deprecated('association option') def setUpAll(self): global items, item_keywords, keywords, metadata, Item, Keyword, KeywordAssociation @@ -141,7 +141,7 @@ class AssociationTest(PersistTest): sess.flush() self.assert_(item_keywords.count().scalar() == 0) -class AssociationTest2(PersistTest): +class AssociationTest2(TestBase): def setUpAll(self): global table_originals, table_people, table_isauthor, metadata, Originals, People, IsAuthor metadata = MetaData(testing.db) diff --git a/test/orm/assorted_eager.py b/test/orm/assorted_eager.py index c4d817ea9..92637bc79 100644 --- a/test/orm/assorted_eager.py +++ b/test/orm/assorted_eager.py @@ -8,7 +8,7 @@ from sqlalchemy.ext.sessioncontext import SessionContext from testlib import * from testlib import fixtures -class EagerTest(AssertMixin): +class EagerTest(TestBase, AssertsExecutionResults): def setUpAll(self): global dbmeta, owners, categories, tests, options, Owner, Category, Test, Option, false dbmeta = MetaData(testing.db) @@ -215,7 +215,7 @@ class EagerTest(AssertMixin): print result assert result == [u'3 Some Category'] -class EagerTest2(AssertMixin): +class EagerTest2(TestBase, AssertsExecutionResults): def setUpAll(self): global metadata, middle, left, right metadata = MetaData(testing.db) diff --git a/test/orm/attributes.py b/test/orm/attributes.py index 4b6e5e19b..27860517c 100644 --- a/test/orm/attributes.py +++ b/test/orm/attributes.py @@ -13,7 +13,7 @@ ROLLBACK_SUPPORTED=False class MyTest(object):pass class MyTest2(object):pass -class AttributesTest(PersistTest): +class AttributesTest(TestBase): def test_basic(self): class User(object):pass @@ -435,7 +435,7 @@ class AttributesTest(PersistTest): assert False -class BackrefTest(PersistTest): +class BackrefTest(TestBase): def test_manytomany(self): class Student(object):pass @@ -508,7 +508,7 @@ class BackrefTest(PersistTest): j.port = None self.assert_(p.jack is None) -class DeferredBackrefTest(PersistTest): +class DeferredBackrefTest(TestBase): def setUp(self): global Post, Blog, called, lazy_load @@ -596,7 +596,7 @@ class DeferredBackrefTest(PersistTest): called[0] = 0 lazy_load = (p1, p2, p3) = [Post("post 1"), Post("post 2"), Post("post 3")] -class HistoryTest(PersistTest): +class HistoryTest(TestBase): def test_scalar(self): class Foo(fixtures.Base): pass diff --git a/test/orm/cascade.py b/test/orm/cascade.py index aa497d81b..722265577 100644 --- a/test/orm/cascade.py +++ b/test/orm/cascade.py @@ -7,7 +7,7 @@ from sqlalchemy.ext.sessioncontext import SessionContext from testlib import * import testlib.tables as tables -class O2MCascadeTest(AssertMixin): +class O2MCascadeTest(TestBase, AssertsExecutionResults): def tearDown(self): tables.delete() @@ -175,7 +175,7 @@ class O2MCascadeTest(AssertMixin): self.assert_(tables.orderitems.count(tables.orders.c.user_id.in_(ids) &(tables.orderitems.c.order_id==tables.orders.c.order_id)).scalar() == 0) -class M2OCascadeTest(AssertMixin): +class M2OCascadeTest(TestBase, AssertsExecutionResults): def tearDown(self): ctx.current.clear() for t in metadata.table_iterator(reverse=True): @@ -275,7 +275,7 @@ class M2OCascadeTest(AssertMixin): -class M2MCascadeTest(AssertMixin): +class M2MCascadeTest(TestBase, AssertsExecutionResults): def setUpAll(self): global metadata, a, b, atob metadata = MetaData(testing.db) @@ -470,7 +470,7 @@ class UnsavedOrphansTest2(ORMTest): assert item.id is None assert attr.id is None -class DoubleParentOrphanTest(AssertMixin): +class DoubleParentOrphanTest(TestBase, AssertsExecutionResults): """test orphan detection for an entity with two parent relations""" def setUpAll(self): @@ -537,7 +537,7 @@ class DoubleParentOrphanTest(AssertMixin): except exceptions.FlushError, e: assert True -class CollectionAssignmentOrphanTest(AssertMixin): +class CollectionAssignmentOrphanTest(TestBase, AssertsExecutionResults): def setUpAll(self): global metadata, table_a, table_b diff --git a/test/orm/collection.py b/test/orm/collection.py index d67ec980c..4011ac2ce 100644 --- a/test/orm/collection.py +++ b/test/orm/collection.py @@ -55,7 +55,7 @@ def dictable_entity(a=None, b=None, c=None): return Entity(a or str(_id), b or 'value %s' % _id, c) -class CollectionsTest(PersistTest): +class CollectionsTest(TestBase): def _test_adapter(self, typecallable, creator=entity_maker, to_set=None): class Foo(object): diff --git a/test/orm/compile.py b/test/orm/compile.py index 5bcca57df..31b686062 100644 --- a/test/orm/compile.py +++ b/test/orm/compile.py @@ -5,7 +5,7 @@ from sqlalchemy.orm import * from testlib import * -class CompileTest(AssertMixin): +class CompileTest(TestBase, AssertsExecutionResults): """test various mapper compilation scenarios""" def tearDown(self): clear_mappers() diff --git a/test/orm/cycles.py b/test/orm/cycles.py index be61a84ff..f956a4529 100644 --- a/test/orm/cycles.py +++ b/test/orm/cycles.py @@ -20,7 +20,7 @@ class Tester(object): def __repr__(self): return "%s(%s)" % (self.__class__.__name__, repr(self.data)) -class SelfReferentialTest(AssertMixin): +class SelfReferentialTest(TestBase, AssertsExecutionResults): """tests a self-referential mapper, with an additional list of child objects.""" def setUpAll(self): global t1, t2, metadata @@ -106,7 +106,7 @@ class SelfReferentialTest(AssertMixin): sess.delete(a) sess.flush() -class SelfReferentialNoPKTest(AssertMixin): +class SelfReferentialNoPKTest(TestBase, AssertsExecutionResults): """test self-referential relationship that joins on a column other than the primary key column""" def setUpAll(self): global table, meta @@ -152,7 +152,7 @@ class SelfReferentialNoPKTest(AssertMixin): assert t.uuid == t2.uuid assert t.parent.uuid == t1.uuid -class InheritTestOne(AssertMixin): +class InheritTestOne(TestBase, AssertsExecutionResults): def setUpAll(self): global parent, child1, child2, meta meta = MetaData(testing.db) @@ -353,7 +353,7 @@ class BiDirectionalManyToOneTest(ORMTest): sess.save(o3) sess.flush() -class BiDirectionalOneToManyTest(AssertMixin): +class BiDirectionalOneToManyTest(TestBase, AssertsExecutionResults): """tests two mappers with a one-to-many relation to each other.""" def setUpAll(self): global t1, t2, metadata @@ -394,7 +394,7 @@ class BiDirectionalOneToManyTest(AssertMixin): [sess.save(x) for x in [a,b,c,d,e,f]] sess.flush() -class BiDirectionalOneToManyTest2(AssertMixin): +class BiDirectionalOneToManyTest2(TestBase, AssertsExecutionResults): """tests two mappers with a one-to-many relation to each other, with a second one-to-many on one of the mappers""" def setUpAll(self): global t1, t2, t3, metadata @@ -454,7 +454,7 @@ class BiDirectionalOneToManyTest2(AssertMixin): sess.delete(c) sess.flush() -class OneToManyManyToOneTest(AssertMixin): +class OneToManyManyToOneTest(TestBase, AssertsExecutionResults): """tests two mappers, one has a one-to-many on the other mapper, the other has a separate many-to-one relationship to the first. two tests will have a row for each item that is dependent on the other. without the "post_update" flag, such relationships raise an exception when dependencies are sorted.""" @@ -744,7 +744,7 @@ class OneToManyManyToOneTest(AssertMixin): ) ]) -class SelfReferentialPostUpdateTest(AssertMixin): +class SelfReferentialPostUpdateTest(TestBase, AssertsExecutionResults): """test using post_update on a single self-referential mapper""" def setUpAll(self): global metadata, node_table @@ -848,7 +848,7 @@ class SelfReferentialPostUpdateTest(AssertMixin): ), ]) -class SelfReferentialPostUpdateTest2(AssertMixin): +class SelfReferentialPostUpdateTest2(TestBase, AssertsExecutionResults): def setUpAll(self): global metadata, a_table metadata = MetaData(testing.db) diff --git a/test/orm/entity.py b/test/orm/entity.py index c56d22f9d..760f8fce9 100644 --- a/test/orm/entity.py +++ b/test/orm/entity.py @@ -5,7 +5,7 @@ from sqlalchemy.ext.sessioncontext import SessionContext from testlib import * from testlib.tables import * -class EntityTest(AssertMixin): +class EntityTest(TestBase, AssertsExecutionResults): """tests mappers that are constructed based on "entity names", which allows the same class to have multiple primary mappers """ diff --git a/test/orm/generative.py b/test/orm/generative.py index ee8f10969..9967f34f7 100644 --- a/test/orm/generative.py +++ b/test/orm/generative.py @@ -12,7 +12,7 @@ class Foo(object): for k in kwargs: setattr(self, k, kwargs[k]) -class GenerativeQueryTest(PersistTest): +class GenerativeQueryTest(TestBase): def setUpAll(self): global foo, metadata metadata = MetaData(testing.db) @@ -119,7 +119,7 @@ class Obj1(object): class Obj2(object): pass -class GenerativeTest2(PersistTest): +class GenerativeTest2(TestBase): def setUpAll(self): global metadata, table1, table2 metadata = MetaData() @@ -149,7 +149,7 @@ class GenerativeTest2(PersistTest): res = query.filter(and_(table1.c.id==table2.c.t1id,table2.c.t1id==1)).distinct() self.assertEqual(res.count(), 1) -class RelationsTest(AssertMixin): +class RelationsTest(TestBase, AssertsExecutionResults): def setUpAll(self): tables.create() tables.data() @@ -206,7 +206,7 @@ class RelationsTest(AssertMixin): self.assert_result(list(x), tables.User, *tables.user_result[1:3]) -class CaseSensitiveTest(PersistTest): +class CaseSensitiveTest(TestBase): def setUpAll(self): global metadata, table1, table2 metadata = MetaData(testing.db) diff --git a/test/orm/inheritance/polymorph2.py b/test/orm/inheritance/polymorph2.py index 75ec0c2b5..ae3f4eaf6 100644 --- a/test/orm/inheritance/polymorph2.py +++ b/test/orm/inheritance/polymorph2.py @@ -612,7 +612,7 @@ class RelationTest7(ORMTest): for p in r: assert p.car_id == p.car.car_id -class GenerativeTest(AssertMixin): +class GenerativeTest(TestBase, AssertsExecutionResults): def setUpAll(self): # cars---owned by--- people (abstract) --- has a --- status # | ^ ^ | diff --git a/test/orm/inheritance/single.py b/test/orm/inheritance/single.py index 22ca25bf0..81223cc02 100644 --- a/test/orm/inheritance/single.py +++ b/test/orm/inheritance/single.py @@ -4,7 +4,7 @@ from sqlalchemy.orm import * from testlib import * -class SingleInheritanceTest(AssertMixin): +class SingleInheritanceTest(TestBase, AssertsExecutionResults): def setUpAll(self): metadata = MetaData(testing.db) global employees_table diff --git a/test/orm/lazytest1.py b/test/orm/lazytest1.py index 40f425abe..90cbbe208 100644 --- a/test/orm/lazytest1.py +++ b/test/orm/lazytest1.py @@ -3,7 +3,7 @@ from sqlalchemy import * from sqlalchemy.orm import * from testlib import * -class LazyTest(AssertMixin): +class LazyTest(TestBase, AssertsExecutionResults): def setUpAll(self): global info_table, data_table, rel_table, metadata metadata = MetaData(testing.db) diff --git a/test/orm/mapper.py b/test/orm/mapper.py index a8f75a31b..6d36b7216 100644 --- a/test/orm/mapper.py +++ b/test/orm/mapper.py @@ -10,7 +10,7 @@ from testlib.tables import * import testlib.tables as tables -class MapperSuperTest(AssertMixin): +class MapperSuperTest(TestBase, AssertsExecutionResults): def setUpAll(self): tables.create() tables.data() @@ -1238,7 +1238,7 @@ class NoLoadTest(MapperSuperTest): {'user_id' : 7, 'addresses' : (Address, [{'address_id' : 1}])}, ) -class MapperExtensionTest(PersistTest): +class MapperExtensionTest(TestBase): def setUpAll(self): tables.create() @@ -1387,7 +1387,7 @@ class MapperExtensionTest(PersistTest): self.assertEquals(methods, ['before_insert', 'after_insert', 'load', 'translate_row', 'populate_instance', 'get', 'translate_row', 'create_instance', 'populate_instance', 'before_update', 'after_update', 'before_delete', 'after_delete']) -class RequirementsTest(AssertMixin): +class RequirementsTest(TestBase, AssertsExecutionResults): """Tests the contract for user classes.""" def setUpAll(self): diff --git a/test/orm/memusage.py b/test/orm/memusage.py index 87471842f..2b3081c6b 100644 --- a/test/orm/memusage.py +++ b/test/orm/memusage.py @@ -37,7 +37,7 @@ def assert_no_mappers(): gc.collect() assert len(_mapper_registry) == 0 -class EnsureZeroed(AssertMixin): +class EnsureZeroed(TestBase, AssertsExecutionResults): def setUp(self): _sessions.clear() _mapper_registry.clear() diff --git a/test/orm/merge.py b/test/orm/merge.py index cbaf752d1..b9a247289 100644 --- a/test/orm/merge.py +++ b/test/orm/merge.py @@ -8,7 +8,7 @@ from testlib import fixtures from testlib.tables import * import testlib.tables as tables -class MergeTest(AssertMixin): +class MergeTest(TestBase, AssertsExecutionResults): """tests session.merge() functionality""" def setUpAll(self): tables.create() diff --git a/test/orm/onetoone.py b/test/orm/onetoone.py index 9c1ea9f16..ae0d6ef86 100644 --- a/test/orm/onetoone.py +++ b/test/orm/onetoone.py @@ -24,7 +24,7 @@ class Port(object): self.name=name self.description = description -class O2OTest(AssertMixin): +class O2OTest(TestBase, AssertsExecutionResults): @testing.uses_deprecated('SessionContext') def setUpAll(self): global jack, port, metadata, ctx diff --git a/test/orm/relationships.py b/test/orm/relationships.py index 40f70bf62..287ee053c 100644 --- a/test/orm/relationships.py +++ b/test/orm/relationships.py @@ -7,7 +7,7 @@ from sqlalchemy.orm import collections from sqlalchemy.orm.collections import collection from testlib import * -class RelationTest(PersistTest): +class RelationTest(TestBase): """An extended topological sort test This is essentially an extension of the "dependency.py" topological sort @@ -104,7 +104,7 @@ class RelationTest(PersistTest): session.delete(c) # fails session.flush() -class RelationTest2(PersistTest): +class RelationTest2(TestBase): """Tests a relationship on a column included in multiple foreign keys. This test tests a relationship on a column that is included in multiple @@ -228,7 +228,7 @@ class RelationTest2(PersistTest): assert sess.query(Employee).get([c1.company_id, 3]).reports_to.name == 'emp1' assert sess.query(Employee).get([c2.company_id, 3]).reports_to.name == 'emp5' -class RelationTest3(PersistTest): +class RelationTest3(TestBase): def setUpAll(self): global jobs, pageversions, pages, metadata, Job, Page, PageVersion, PageComment import datetime diff --git a/test/orm/session.py b/test/orm/session.py index 0a38198ac..a1c850073 100644 --- a/test/orm/session.py +++ b/test/orm/session.py @@ -11,7 +11,7 @@ import pickle import gc -class SessionTest(AssertMixin): +class SessionTest(TestBase, AssertsExecutionResults): def setUpAll(self): tables.create() @@ -967,7 +967,7 @@ class ScopedSessionTest(ORMTest): self.assertEquals(SomeObject(id=1, data="hello", options=[SomeOtherObject(someid=1)]), SomeObject.query.one()) self.assertEquals(SomeOtherObject(someid=1), SomeOtherObject.query.filter(SomeOtherObject.someid==sso.someid).one()) -class ScopedMapperTest(PersistTest): +class ScopedMapperTest(TestBase): def setUpAll(self): global metadata, table, table2 metadata = MetaData(testing.db) diff --git a/test/orm/sessioncontext.py b/test/orm/sessioncontext.py index d6e652477..c743dabf9 100644 --- a/test/orm/sessioncontext.py +++ b/test/orm/sessioncontext.py @@ -12,7 +12,7 @@ users = Table('users', metadata, Column('user_name', String(40)), ) -class SessionContextTest(AssertMixin): +class SessionContextTest(TestBase, AssertsExecutionResults): def setUp(self): clear_mappers() diff --git a/test/orm/sharding/shard.py b/test/orm/sharding/shard.py index 283fac0e3..f0acb1a71 100644 --- a/test/orm/sharding/shard.py +++ b/test/orm/sharding/shard.py @@ -5,11 +5,11 @@ from sqlalchemy import exceptions, sql from sqlalchemy.orm import * from sqlalchemy.orm.shard import ShardedSession from sqlalchemy.sql import operators -from testlib import PersistTest +from testlib import TestBase # TODO: ShardTest can be turned into a base for further subclasses -class ShardTest(PersistTest): +class ShardTest(TestBase): def setUpAll(self): global db1, db2, db3, db4, weather_locations, weather_reports diff --git a/test/perf/massload.py b/test/perf/massload.py index 6fdda3f4d..834333083 100644 --- a/test/perf/massload.py +++ b/test/perf/massload.py @@ -17,7 +17,7 @@ top while it runs NUM = 2500 -class LoadTest(AssertMixin): +class LoadTest(TestBase, AssertsExecutionResults): def setUpAll(self): global items, meta meta = MetaData(testing.db) diff --git a/test/perf/masssave.py b/test/perf/masssave.py index c0d041a41..bf65c8fdf 100644 --- a/test/perf/masssave.py +++ b/test/perf/masssave.py @@ -7,7 +7,7 @@ from testlib import * NUM = 2500 -class SaveTest(AssertMixin): +class SaveTest(TestBase, AssertsExecutionResults): def setUpAll(self): global items, metadata metadata = MetaData(testing.db) diff --git a/test/perf/sessions.py b/test/perf/sessions.py index 0a050358a..c5f768653 100644 --- a/test/perf/sessions.py +++ b/test/perf/sessions.py @@ -9,7 +9,7 @@ import gc ITERATIONS = 100 -class SessionTest(AssertMixin): +class SessionTest(TestBase, AssertsExecutionResults): def setUpAll(self): global t1, t2, metadata,T1, T2 metadata = MetaData(testing.db) diff --git a/test/profiling/compiler.py b/test/profiling/compiler.py index 330271a1c..51ec25e38 100644 --- a/test/profiling/compiler.py +++ b/test/profiling/compiler.py @@ -3,7 +3,7 @@ from sqlalchemy import * from testlib import * -class CompileTest(AssertMixin): +class CompileTest(TestBase, AssertsExecutionResults): def setUpAll(self): global t1, t2, metadata metadata = MetaData() diff --git a/test/profiling/pool.py b/test/profiling/pool.py index 92c488382..a8167a1ba 100644 --- a/test/profiling/pool.py +++ b/test/profiling/pool.py @@ -4,7 +4,7 @@ from testlib import * from sqlalchemy.pool import QueuePool from sqlalchemy.databases import sqlite -class QueuePoolTest(AssertMixin): +class QueuePoolTest(TestBase, AssertsExecutionResults): def setUp(self): global pool pool = QueuePool(creator = lambda: sqlite.SQLiteDialect.dbapi().connect(':memory:'), pool_size = 3, max_overflow = -1, use_threadlocal = True) diff --git a/test/profiling/zoomark.py b/test/profiling/zoomark.py index f78036123..f0208acb4 100644 --- a/test/profiling/zoomark.py +++ b/test/profiling/zoomark.py @@ -7,16 +7,15 @@ import datetime import sys import time import testenv; testenv.configure_for_tests() -from testlib import engines, testing, profiling from sqlalchemy import * -from testlib import set +from testlib import * ITERATIONS = 1 _run_type = 'suite' _running_in = lambda: _run_type -class ZooMarkTest(testing.AssertMixin): +class ZooMarkTest(testing.TestBase, AssertsExecutionResults): """Runs the ZooMark and squawks if method counts vary from the norm. Each test has an associated `call_range`, the total number of accepted @@ -29,7 +28,7 @@ class ZooMarkTest(testing.AssertMixin): @profiling.conditional_call_count( _running_in, {'isolation': (1806,), - 'suite': (1569, {'2.4': 1579})}) + 'suite': (1569, {'2.4': 1579}, 0.20)}) def test_1_create_tables(self): global metadata metadata = MetaData(testing.db) diff --git a/test/sql/case_statement.py b/test/sql/case_statement.py index 6476537b0..ab68b5210 100644 --- a/test/sql/case_statement.py +++ b/test/sql/case_statement.py @@ -4,7 +4,7 @@ from sqlalchemy import * from testlib import * -class CaseTest(PersistTest): +class CaseTest(TestBase): def setUpAll(self): metadata = MetaData(testing.db) diff --git a/test/sql/constraints.py b/test/sql/constraints.py index 29fffa751..2908e07da 100644 --- a/test/sql/constraints.py +++ b/test/sql/constraints.py @@ -4,7 +4,7 @@ from sqlalchemy import exceptions from testlib import * from testlib import config, engines -class ConstraintTest(AssertMixin): +class ConstraintTest(TestBase, AssertsExecutionResults): def setUp(self): global metadata @@ -202,7 +202,7 @@ class ConstraintTest(AssertMixin): ss = events.select().execute().fetchall() -class ConstraintCompilationTest(AssertMixin): +class ConstraintCompilationTest(TestBase, AssertsExecutionResults): class accum(object): def __init__(self): self.statements = [] diff --git a/test/sql/defaults.py b/test/sql/defaults.py index 9b8485231..22660c060 100644 --- a/test/sql/defaults.py +++ b/test/sql/defaults.py @@ -6,7 +6,7 @@ from sqlalchemy.orm import mapper, create_session from testlib import * -class DefaultTest(PersistTest): +class DefaultTest(TestBase): def setUpAll(self): global t, f, f2, ts, currenttime, metadata, default_generator @@ -267,7 +267,7 @@ class DefaultTest(PersistTest): finally: testing.db.execute("drop table speedy_users", None) -class PKDefaultTest(PersistTest): +class PKDefaultTest(TestBase): def setUpAll(self): global metadata, t1, t2 @@ -296,7 +296,7 @@ class PKDefaultTest(PersistTest): assert r.last_inserted_ids() == [2] -class AutoIncrementTest(PersistTest): +class AutoIncrementTest(TestBase): def setUp(self): global aitable, aimeta @@ -406,7 +406,7 @@ class AutoIncrementTest(PersistTest): metadata.drop_all() -class SequenceTest(PersistTest): +class SequenceTest(TestBase): __unsupported_on__ = ('sqlite', 'mysql', 'mssql', 'firebird', 'sybase', 'access') diff --git a/test/sql/functions.py b/test/sql/functions.py index fe4bbd7ac..f6b1e67f1 100644 --- a/test/sql/functions.py +++ b/test/sql/functions.py @@ -21,7 +21,7 @@ if testing.db.name not in databases.__all__: dialects.append(testing.db.dialect) -class CompileTest(SQLCompileTest): +class CompileTest(TestBase, AssertsCompiledSQL): def test_compile(self): for dialect in dialects: bindtemplate = BIND_TEMPLATES[dialect.paramstyle] @@ -139,7 +139,7 @@ class CompileTest(SQLCompileTest): , checkparams={'y_1': 45, 'x_1': 17, 'y_2': 12, 'x_2': 5}) -class ExecuteTest(PersistTest): +class ExecuteTest(TestBase): def test_standalone_execute(self): x = testing.db.func.current_date().execute().scalar() diff --git a/test/sql/generative.py b/test/sql/generative.py index 26d78c6f0..831c2e287 100644 --- a/test/sql/generative.py +++ b/test/sql/generative.py @@ -8,7 +8,7 @@ from sqlalchemy import util from sqlalchemy.sql import util as sql_util -class TraversalTest(AssertMixin): +class TraversalTest(TestBase, AssertsExecutionResults): """test ClauseVisitor's traversal, particularly its ability to copy and modify a ClauseElement in place.""" @@ -138,7 +138,7 @@ class TraversalTest(AssertMixin): assert struct3 == s3 -class ClauseTest(SQLCompileTest): +class ClauseTest(TestBase, AssertsCompiledSQL): """test copy-in-place behavior of various ClauseElements.""" def setUpAll(self): @@ -270,7 +270,7 @@ class ClauseTest(SQLCompileTest): self.assert_compile(Vis().traverse(s, clone=True), "SELECT * FROM table1 WHERE table1.col1 = table2.col1 AND table1.col2 = :table1_col2_1") -class ClauseAdapterTest(SQLCompileTest): +class ClauseAdapterTest(TestBase, AssertsCompiledSQL): def setUpAll(self): global t1, t2 t1 = table("table1", @@ -410,7 +410,7 @@ class ClauseAdapterTest(SQLCompileTest): "LEFT OUTER JOIN table1 AS bar ON anon_1.col1 = bar.col1") -class SelectTest(SQLCompileTest): +class SelectTest(TestBase, AssertsCompiledSQL): """tests the generative capability of Select""" def setUpAll(self): diff --git a/test/sql/labels.py b/test/sql/labels.py index 8164d7f77..a46d0a650 100644 --- a/test/sql/labels.py +++ b/test/sql/labels.py @@ -8,7 +8,7 @@ from sqlalchemy.engine import default IDENT_LENGTH = 29 -class LabelTypeTest(PersistTest): +class LabelTypeTest(TestBase): def test_type(self): m = MetaData() t = Table('sometable', m, @@ -17,7 +17,7 @@ class LabelTypeTest(PersistTest): assert isinstance(t.c.col1.label('hi').type, Integer) assert isinstance(select([t.c.col2]).as_scalar().label('lala').type, Float) -class LongLabelsTest(SQLCompileTest): +class LongLabelsTest(TestBase, AssertsCompiledSQL): def setUpAll(self): global metadata, table1, maxlen metadata = MetaData(testing.db) diff --git a/test/sql/query.py b/test/sql/query.py index 19d11a2f1..533f40fb5 100644 --- a/test/sql/query.py +++ b/test/sql/query.py @@ -6,7 +6,7 @@ from sqlalchemy.engine import default from testlib import * -class QueryTest(PersistTest): +class QueryTest(TestBase): def setUpAll(self): global users, addresses, metadata @@ -557,7 +557,7 @@ class QueryTest(PersistTest): assert len(r) == 1 -class CompoundTest(PersistTest): +class CompoundTest(TestBase): """test compound statements like UNION, INTERSECT, particularly their ability to nest on different databases.""" def setUpAll(self): @@ -755,7 +755,7 @@ class CompoundTest(PersistTest): self.assertEquals(found, wanted) -class JoinTest(PersistTest): +class JoinTest(TestBase): """Tests join execution. The compiled SQL emitted by the dialect might be ANSI joins or @@ -1025,7 +1025,7 @@ class JoinTest(PersistTest): self.assertRows(expr, [(10, 20, 30)]) -class OperatorTest(PersistTest): +class OperatorTest(TestBase): def setUpAll(self): global metadata, flds metadata = MetaData(testing.db) diff --git a/test/sql/quote.py b/test/sql/quote.py index ee7164836..825e836ff 100644 --- a/test/sql/quote.py +++ b/test/sql/quote.py @@ -4,7 +4,7 @@ from sqlalchemy import sql from sqlalchemy.sql import compiler from testlib import * -class QuoteTest(PersistTest): +class QuoteTest(TestBase): def setUpAll(self): # TODO: figure out which databases/which identifiers allow special characters to be used, # such as: spaces, quote characters, punctuation characters, set up tests for those as @@ -98,7 +98,7 @@ class QuoteTest(PersistTest): assert str(x) == '''SELECT "SomeLabel" \nFROM (SELECT 'FooCol' AS "SomeLabel" \nFROM "ImATable")''' -class PreparerTest(PersistTest): +class PreparerTest(TestBase): """Test the db-agnostic quoting services of IdentifierPreparer.""" def test_unformat(self): diff --git a/test/sql/rowcount.py b/test/sql/rowcount.py index dc90c1945..3c9caad75 100644 --- a/test/sql/rowcount.py +++ b/test/sql/rowcount.py @@ -3,7 +3,7 @@ from sqlalchemy import * from testlib import * -class FoundRowsTest(AssertMixin): +class FoundRowsTest(TestBase, AssertsExecutionResults): """tests rowcount functionality""" def setUpAll(self): metadata = MetaData(testing.db) diff --git a/test/sql/select.py b/test/sql/select.py index 54b1e87a2..39906dcdb 100644 --- a/test/sql/select.py +++ b/test/sql/select.py @@ -48,7 +48,7 @@ addresses = table('addresses', column('zip') ) -class SelectTest(SQLCompileTest): +class SelectTest(TestBase, AssertsCompiledSQL): def test_attribute_sanity(self): assert hasattr(table1, 'c') @@ -1198,7 +1198,7 @@ UNION SELECT mytable.myid, mytable.name, mytable.description FROM mytable WHERE else: self.assert_compile(s1, "SELECT %s FROM (SELECT %s FROM mytable)" % (expr,expr)) -class CRUDTest(SQLCompileTest): +class CRUDTest(TestBase, AssertsCompiledSQL): def test_insert(self): # generic insert, will create bind params for all columns self.assert_compile(insert(table1), "INSERT INTO mytable (myid, name, description) VALUES (:myid, :name, :description)") @@ -1304,7 +1304,7 @@ class CRUDTest(SQLCompileTest): u = table1.delete(table1.c.name==s) self.assert_compile(u, "DELETE FROM mytable WHERE mytable.name = (SELECT myothertable.othername FROM myothertable WHERE myothertable.otherid = mytable.myid)") -class InlineDefaultTest(SQLCompileTest): +class InlineDefaultTest(TestBase, AssertsCompiledSQL): def test_insert(self): m = MetaData() foo = Table('foo', m, @@ -1330,7 +1330,7 @@ class InlineDefaultTest(SQLCompileTest): self.assert_compile(t.update(inline=True, values={'col3':'foo'}), "UPDATE test SET col1=foo(:foo_1), col2=(SELECT coalesce(max(foo.id)) AS coalesce_1 FROM foo), col3=:col3") -class SchemaTest(SQLCompileTest): +class SchemaTest(TestBase, AssertsCompiledSQL): @testing.fails_on('mssql') def test_select(self): # these tests will fail with the MS-SQL compiler since it will alias schema-qualified tables diff --git a/test/sql/selectable.py b/test/sql/selectable.py index fe2f41b2b..c93c62825 100755 --- a/test/sql/selectable.py +++ b/test/sql/selectable.py @@ -23,7 +23,7 @@ table2 = Table('table2', metadata, Column('coly', Integer), ) -class SelectableTest(AssertMixin): +class SelectableTest(TestBase, AssertsExecutionResults): def testdistance(self): # same column three times s = select([table.c.col1.label('c2'), table.c.col1, table.c.col1.label('c1')]) @@ -212,7 +212,7 @@ class SelectableTest(AssertMixin): assert u.corresponding_column(s.oid_column) is u.oid_column assert u.corresponding_column(s2.oid_column) is u.oid_column -class PrimaryKeyTest(AssertMixin): +class PrimaryKeyTest(TestBase, AssertsExecutionResults): def test_join_pk_collapse_implicit(self): """test that redundant columns in a join get 'collapsed' into a minimal primary key, which is the root column along a chain of foreign key relationships.""" @@ -297,7 +297,7 @@ class PrimaryKeyTest(AssertMixin): ) -class ReduceTest(AssertMixin): +class ReduceTest(TestBase, AssertsExecutionResults): def test_reduce(self): meta = MetaData() t1 = Table('t1', meta, @@ -411,7 +411,7 @@ class ReduceTest(AssertMixin): ) -class DerivedTest(AssertMixin): +class DerivedTest(TestBase, AssertsExecutionResults): def test_table(self): meta = MetaData() t1 = Table('t1', meta, Column('c1', Integer, primary_key=True), Column('c2', String(30))) diff --git a/test/sql/testtypes.py b/test/sql/testtypes.py index b8de2a302..0c10247e5 100644 --- a/test/sql/testtypes.py +++ b/test/sql/testtypes.py @@ -9,7 +9,7 @@ from testlib import * -class AdaptTest(PersistTest): +class AdaptTest(TestBase): def testadapt(self): e1 = url.URL('postgres').get_dialect()() e2 = url.URL('mysql').get_dialect()() @@ -106,7 +106,7 @@ class AdaptTest(PersistTest): -class UserDefinedTest(PersistTest): +class UserDefinedTest(TestBase): """tests user-defined types.""" def testbasic(self): @@ -266,7 +266,7 @@ class UserDefinedTest(PersistTest): def tearDownAll(self): metadata.drop_all() -class ColumnsTest(AssertMixin): +class ColumnsTest(TestBase, AssertsExecutionResults): def testcolumns(self): expectedResults = { 'int_column': 'int_column INTEGER', @@ -299,7 +299,7 @@ class ColumnsTest(AssertMixin): db.dialect.schemagenerator(db.dialect, db, None, None).\ get_column_specification(aCol)) -class UnicodeTest(AssertMixin): +class UnicodeTest(TestBase, AssertsExecutionResults): """tests the Unicode type. also tests the TypeDecorator with instances in the types package.""" def setUpAll(self): global unicode_table @@ -400,7 +400,7 @@ class UnicodeTest(AssertMixin): teststr = u'aaa\x1234' self.assert_(testing.db.func.length(teststr).scalar() == len(teststr)) -class BinaryTest(AssertMixin): +class BinaryTest(TestBase, AssertsExecutionResults): def setUpAll(self): global binary_table, MyPickleType @@ -467,7 +467,7 @@ class BinaryTest(AssertMixin): # put a number less than the typical MySQL default BLOB size return file(f).read(len) -class ExpressionTest(AssertMixin): +class ExpressionTest(TestBase, AssertsExecutionResults): def setUpAll(self): global test_table, meta @@ -537,7 +537,7 @@ class ExpressionTest(AssertMixin): # processing rules on the column. assert testing.db.execute(select([expr])).scalar() == -15 -class DateTest(AssertMixin): +class DateTest(TestBase, AssertsExecutionResults): def setUpAll(self): global users_with_date, insert_data @@ -662,7 +662,7 @@ class DateTest(AssertMixin): finally: t.drop(checkfirst=True) -class StringTest(AssertMixin): +class StringTest(TestBase, AssertsExecutionResults): def test_nolen_string_deprecated(self): metadata = MetaData(testing.db) foo =Table('foo', metadata, @@ -698,7 +698,7 @@ def _missing_decimal(): except ImportError: return True -class NumericTest(AssertMixin): +class NumericTest(TestBase, AssertsExecutionResults): def setUpAll(self): global numeric_table, metadata metadata = MetaData(testing.db) @@ -750,7 +750,7 @@ class NumericTest(AssertMixin): assert isinstance(row['fcasdec'], util.decimal_type) -class IntervalTest(AssertMixin): +class IntervalTest(TestBase, AssertsExecutionResults): def setUpAll(self): global interval_table, metadata metadata = MetaData(testing.db) @@ -775,7 +775,7 @@ class IntervalTest(AssertMixin): interval_table.insert().execute(id=1, inverval=None) assert interval_table.select().execute().fetchone()['interval'] is None -class BooleanTest(AssertMixin): +class BooleanTest(TestBase, AssertsExecutionResults): def setUpAll(self): global bool_table metadata = MetaData(testing.db) diff --git a/test/sql/unicode.py b/test/sql/unicode.py index 54d453025..9e3ea257e 100644 --- a/test/sql/unicode.py +++ b/test/sql/unicode.py @@ -7,7 +7,7 @@ from testlib import * from testlib.engines import utf8_engine from sqlalchemy.sql import column -class UnicodeSchemaTest(PersistTest): +class UnicodeSchemaTest(TestBase): @testing.unsupported('maxdb', 'oracle', 'sybase') def setUpAll(self): global unicode_bind, metadata, t1, t2, t3 @@ -112,7 +112,7 @@ class UnicodeSchemaTest(PersistTest): meta.drop_all() metadata.create_all() -class EscapesDefaultsTest(testing.PersistTest): +class EscapesDefaultsTest(testing.TestBase): def test_default_exec(self): metadata = MetaData(testing.db) t1 = Table('t1', metadata, diff --git a/test/testlib/__init__.py b/test/testlib/__init__.py index 1cb3647e2..98552b0f3 100644 --- a/test/testlib/__init__.py +++ b/test/testlib/__init__.py @@ -8,7 +8,7 @@ from testlib.schema import Table, Column from testlib.orm import mapper import testlib.testing as testing from testlib.testing import rowset -from testlib.testing import PersistTest, AssertMixin, ORMTest, SQLCompileTest, ComparesTables +from testlib.testing import TestBase, AssertsExecutionResults, ORMTest, AssertsCompiledSQL, ComparesTables import testlib.profiling as profiling import testlib.engines as engines from testlib.compat import set, frozenset, sorted, _function_named @@ -18,6 +18,6 @@ __all__ = ('testing', 'mapper', 'Table', 'Column', 'rowset', - 'PersistTest', 'AssertMixin', 'ORMTest', 'SQLCompileTest', 'ComparesTables', + 'TestBase', 'AssertsExecutionResults', 'ORMTest', 'AssertsCompiledSQL', 'ComparesTables', 'profiling', 'engines', 'set', 'frozenset', 'sorted', '_function_named') diff --git a/test/testlib/testing.py b/test/testlib/testing.py index 5c37f95bd..8a3028799 100644 --- a/test/testlib/testing.py +++ b/test/testlib/testing.py @@ -10,7 +10,7 @@ from testlib.compat import * sql, sqltypes, schema, MetaData, clear_mappers, Session, util = None, None, None, None, None, None, None sa_exceptions = None -__all__ = ('PersistTest', 'AssertMixin', 'ComparesTables', 'ORMTest', 'SQLCompileTest') +__all__ = ('TestBase', 'AssertsExecutionResults', 'ComparesTables', 'ORMTest', 'AssertsCompiledSQL') _ops = { '<': operator.lt, '>': operator.gt, @@ -434,7 +434,7 @@ class ExecutionContextWrapper(object): query = re.sub(r':([\w_]+)', repl, query) return query -class PersistTest(unittest.TestCase): +class TestBase(unittest.TestCase): # A sequence of dialect names to exclude from the test class. __unsupported_on__ = () @@ -464,7 +464,7 @@ class PersistTest(unittest.TestCase): if not hasattr(unittest.TestCase, 'assertFalse'): assertFalse = unittest.TestCase.failIf -class SQLCompileTest(PersistTest): +class AssertsCompiledSQL(object): def assert_compile(self, clause, result, params=None, checkparams=None, dialect=None): if dialect is None: dialect = getattr(self, '__dialect__', None) @@ -519,7 +519,7 @@ class ComparesTables(object): assert reflected_table.primary_key.columns[c.name] -class AssertMixin(PersistTest): +class AssertsExecutionResults(object): def assert_result(self, result, class_, *objects): result = list(result) print repr(result) @@ -629,7 +629,7 @@ class AssertMixin(PersistTest): testdata.buffer = None _otest_metadata = None -class ORMTest(AssertMixin): +class ORMTest(TestBase, AssertsExecutionResults): keep_mappers = False keep_data = False metadata = None @@ -690,7 +690,7 @@ class TTestSuite(unittest.TestSuite): """A TestSuite with once per TestCase setUpAll() and tearDownAll()""" def __init__(self, tests=()): - if len(tests) > 0 and isinstance(tests[0], PersistTest): + if len(tests) > 0 and isinstance(tests[0], TestBase): self._initTest = tests[0] else: self._initTest = None diff --git a/test/zblog/tests.py b/test/zblog/tests.py index 066473085..4f77d350d 100644 --- a/test/zblog/tests.py +++ b/test/zblog/tests.py @@ -7,7 +7,7 @@ from zblog.user import * from zblog.blog import * -class ZBlogTest(AssertMixin): +class ZBlogTest(TestBase, AssertsExecutionResults): def create_tables(self): tables.metadata.drop_all(bind=testing.db) |