From: Mike Bayer Date: Sun, 27 Mar 2011 20:27:27 +0000 (-0400) Subject: - remove test.sql._base, test.engine._base, test.orm._base, move those classes to... X-Git-Tag: rel_0_7b4~55 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=68a350d462b6840d6623a89565f8febf3a997830;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - remove test.sql._base, test.engine._base, test.orm._base, move those classes to a new test.lib.fixtures module - move testing.TestBase to test.lib.fixtures - massive search and replace --- diff --git a/examples/versioning/test_versioning.py b/examples/versioning/test_versioning.py index 83d769e1ef..d2d270c432 100644 --- a/examples/versioning/test_versioning.py +++ b/examples/versioning/test_versioning.py @@ -9,7 +9,7 @@ def setup(): global engine engine = create_engine('sqlite://', echo=True) -class TestVersioning(TestBase): +class TestVersioning(fixtures.TestBase): def setup(self): global Base, Session, Versioned Base = declarative_base(bind=engine) diff --git a/lib/sqlalchemy/orm/dynamic.py b/lib/sqlalchemy/orm/dynamic.py index bdcb7b6b26..d4a031d9a2 100644 --- a/lib/sqlalchemy/orm/dynamic.py +++ b/lib/sqlalchemy/orm/dynamic.py @@ -101,7 +101,7 @@ class DynamicAttributeImpl(attributes.AttributeImpl): self, attributes.NEVER_SET) - # this is a hack to allow the _base.ComparableEntity fixture + # this is a hack to allow the fixtures.ComparableEntity fixture # to work dict_[self.key] = True return state.committed_state[self.key] diff --git a/test/aaa_profiling/test_compiler.py b/test/aaa_profiling/test_compiler.py index 697ab5952c..f68e82b073 100644 --- a/test/aaa_profiling/test_compiler.py +++ b/test/aaa_profiling/test_compiler.py @@ -2,7 +2,7 @@ from sqlalchemy import * from test.lib import * from sqlalchemy.engine import default -class CompileTest(TestBase, AssertsExecutionResults): +class CompileTest(fixtures.TestBase, AssertsExecutionResults): @classmethod def setup_class(cls): diff --git a/test/aaa_profiling/test_memusage.py b/test/aaa_profiling/test_memusage.py index 3e225ad088..80939376ca 100644 --- a/test/aaa_profiling/test_memusage.py +++ b/test/aaa_profiling/test_memusage.py @@ -17,16 +17,16 @@ from test.lib.util import gc_collect from sqlalchemy.util.compat import decimal import gc import weakref -from test.orm import _base +from test.lib import fixtures if jython: from nose import SkipTest raise SkipTest("Profiling not supported on this platform") -class A(_base.ComparableEntity): +class A(fixtures.ComparableEntity): pass -class B(_base.ComparableEntity): +class B(fixtures.ComparableEntity): pass def profile_memory(func): @@ -68,7 +68,7 @@ def assert_no_mappers(): gc_collect() assert len(_mapper_registry) == 0 -class EnsureZeroed(_base.ORMTest): +class EnsureZeroed(fixtures.ORMTest): def setup(self): _sessions.clear() _mapper_registry.clear() @@ -388,7 +388,7 @@ class MemUsageTest(EnsureZeroed): @profile_memory def go(): - class A(_base.ComparableEntity): + class A(fixtures.ComparableEntity): pass class B(A): pass @@ -454,9 +454,9 @@ class MemUsageTest(EnsureZeroed): @profile_memory def go(): - class A(_base.ComparableEntity): + class A(fixtures.ComparableEntity): pass - class B(_base.ComparableEntity): + class B(fixtures.ComparableEntity): pass mapper(A, table1, properties={ diff --git a/test/aaa_profiling/test_orm.py b/test/aaa_profiling/test_orm.py index 96457a18a5..b0b0128616 100644 --- a/test/aaa_profiling/test_orm.py +++ b/test/aaa_profiling/test_orm.py @@ -4,11 +4,11 @@ from sqlalchemy import exc as sa_exc, util, Integer, String, ForeignKey from sqlalchemy.orm import exc as orm_exc, mapper, relationship, \ sessionmaker, Session from test.lib import testing, profiling -from test.orm import _base +from test.lib import fixtures from test.lib.schema import Table, Column import sys -class MergeTest(_base.MappedTest): +class MergeTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -101,7 +101,7 @@ class MergeTest(_base.MappedTest): sess2 = sessionmaker()() self.assert_sql_count(testing.db, go, 2) -class LoadManyToOneFromIdentityTest(_base.MappedTest): +class LoadManyToOneFromIdentityTest(fixtures.MappedTest): """test overhead associated with many-to-one fetches. Prior to the refactor of LoadLazyAttribute and diff --git a/test/aaa_profiling/test_pool.py b/test/aaa_profiling/test_pool.py index d0486fa0bd..563f8fcb7f 100644 --- a/test/aaa_profiling/test_pool.py +++ b/test/aaa_profiling/test_pool.py @@ -3,7 +3,7 @@ from test.lib import * from sqlalchemy.pool import QueuePool -class QueuePoolTest(TestBase, AssertsExecutionResults): +class QueuePoolTest(fixtures.TestBase, AssertsExecutionResults): class Connection(object): def rollback(self): pass diff --git a/test/aaa_profiling/test_resultset.py b/test/aaa_profiling/test_resultset.py index a0b16cb52b..9ba3d69175 100644 --- a/test/aaa_profiling/test_resultset.py +++ b/test/aaa_profiling/test_resultset.py @@ -4,7 +4,7 @@ NUM_FIELDS = 10 NUM_RECORDS = 1000 -class ResultSetTest(TestBase, AssertsExecutionResults): +class ResultSetTest(fixtures.TestBase, AssertsExecutionResults): __only_on__ = 'sqlite' @@ -52,7 +52,7 @@ class ResultSetTest(TestBase, AssertsExecutionResults): def test_unicode(self): [tuple(row) for row in t2.select().execute().fetchall()] -class ExecutionTest(TestBase): +class ExecutionTest(fixtures.TestBase): __only_on__ = 'sqlite' def test_minimal_connection_execute(self): diff --git a/test/aaa_profiling/test_zoomark.py b/test/aaa_profiling/test_zoomark.py index a201212b9e..c448529167 100644 --- a/test/aaa_profiling/test_zoomark.py +++ b/test/aaa_profiling/test_zoomark.py @@ -13,7 +13,7 @@ dbapi_session = engines.ReplayableSession() metadata = None -class ZooMarkTest(TestBase): +class ZooMarkTest(fixtures.TestBase): """Runs the ZooMark and squawks if method counts vary from the norm. diff --git a/test/aaa_profiling/test_zoomark_orm.py b/test/aaa_profiling/test_zoomark_orm.py index 8479b7a40f..2e7273e018 100644 --- a/test/aaa_profiling/test_zoomark_orm.py +++ b/test/aaa_profiling/test_zoomark_orm.py @@ -14,7 +14,7 @@ dbapi_session = engines.ReplayableSession() metadata = None -class ZooMarkTest(TestBase): +class ZooMarkTest(fixtures.TestBase): """Runs the ZooMark and squawks if method counts vary from the norm. diff --git a/test/base/test_dependency.py b/test/base/test_dependency.py index 9fae92fa12..85347ad913 100644 --- a/test/base/test_dependency.py +++ b/test/base/test_dependency.py @@ -1,10 +1,10 @@ from sqlalchemy.util import topological -from test.lib import TestBase from test.lib.testing import assert_raises, eq_ from test.lib.util import conforms_partial_ordering from sqlalchemy import exc +from test.lib import fixtures -class DependencySortTest(TestBase): +class DependencySortTest(fixtures.TestBase): def assert_sort(self, tuples, allitems=None): if allitems is None: diff --git a/test/base/test_events.py b/test/base/test_events.py index f699a66f20..e6ce125012 100644 --- a/test/base/test_events.py +++ b/test/base/test_events.py @@ -1,9 +1,10 @@ """Test event registration and listening.""" -from test.lib.testing import TestBase, eq_, assert_raises +from test.lib.testing import eq_, assert_raises from sqlalchemy import event, exc, util +from test.lib import fixtures -class TestEvents(TestBase): +class TestEvents(fixtures.TestBase): """Test class- and instance-level event registration.""" def setUp(self): @@ -89,7 +90,7 @@ class TestEvents(TestBase): [listen_three, listen_one, listen_two] ) -class TestAcceptTargets(TestBase): +class TestAcceptTargets(fixtures.TestBase): """Test default target acceptance.""" def setUp(self): @@ -159,7 +160,7 @@ class TestAcceptTargets(TestBase): [listen_two, listen_four] ) -class TestCustomTargets(TestBase): +class TestCustomTargets(fixtures.TestBase): """Test custom target acceptance.""" def setUp(self): @@ -199,7 +200,7 @@ class TestCustomTargets(TestBase): listen, "event_one", Target ) -class TestListenOverride(TestBase): +class TestListenOverride(fixtures.TestBase): """Test custom listen functions which change the listener function signature.""" def setUp(self): @@ -246,7 +247,7 @@ class TestListenOverride(TestBase): ] ) -class TestPropagate(TestBase): +class TestPropagate(fixtures.TestBase): def setUp(self): global Target diff --git a/test/base/test_except.py b/test/base/test_except.py index 044e7c2440..eef247063f 100644 --- a/test/base/test_except.py +++ b/test/base/test_except.py @@ -2,7 +2,7 @@ from sqlalchemy import exc as sa_exceptions -from test.lib import TestBase +from test.lib import fixtures # Py3K #StandardError = BaseException @@ -33,7 +33,7 @@ class OutOfSpec(DatabaseError): pass -class WrapTest(TestBase): +class WrapTest(fixtures.TestBase): def test_db_error_normal(self): try: diff --git a/test/base/test_utils.py b/test/base/test_utils.py index 48fc075eef..981e912a6c 100644 --- a/test/base/test_utils.py +++ b/test/base/test_utils.py @@ -1,13 +1,12 @@ from test.lib.testing import assert_raises, assert_raises_message import copy, threading from sqlalchemy import util, sql, exc -from test.lib import TestBase from test.lib.testing import eq_, is_, ne_, fails_if from test.lib.util import gc_collect, picklers from sqlalchemy.util import classproperty +from test.lib import fixtures - -class OrderedDictTest(TestBase): +class OrderedDictTest(fixtures.TestBase): def test_odict(self): o = util.OrderedDict() o['a'] = 1 @@ -71,7 +70,7 @@ class OrderedDictTest(TestBase): o3 = copy.copy(o) eq_(o3.keys(), o.keys()) -class OrderedSetTest(TestBase): +class OrderedSetTest(fixtures.TestBase): def test_mutators_against_iter(self): # testing a set modified against an iterator o = util.OrderedSet([3,2, 4, 5]) @@ -80,14 +79,14 @@ class OrderedSetTest(TestBase): eq_(o.intersection(iter([3,4, 6])), util.OrderedSet([3, 4])) eq_(o.union(iter([3,4, 6])), util.OrderedSet([2, 3, 4, 5, 6])) -class FrozenDictTest(TestBase): +class FrozenDictTest(fixtures.TestBase): def test_serialize(self): d = util.immutabledict({1:2, 3:4}) for loads, dumps in picklers(): print loads(dumps(d)) -class MemoizedAttrTest(TestBase): +class MemoizedAttrTest(fixtures.TestBase): def test_memoized_property(self): val = [20] class Foo(object): @@ -121,7 +120,7 @@ class MemoizedAttrTest(TestBase): eq_(f1.bar(), 20) eq_(val[0], 21) -class ColumnCollectionTest(TestBase): +class ColumnCollectionTest(fixtures.TestBase): def test_in(self): cc = sql.ColumnCollection() cc.add(sql.column('col1')) @@ -149,7 +148,7 @@ class ColumnCollectionTest(TestBase): assert (cc1==cc2).compare(c1 == c2) assert not (cc1==cc3).compare(c2 == c3) -class LRUTest(TestBase): +class LRUTest(fixtures.TestBase): def test_lru(self): class item(object): @@ -196,7 +195,7 @@ class LRUTest(TestBase): class ImmutableSubclass(str): pass -class FlattenIteratorTest(TestBase): +class FlattenIteratorTest(fixtures.TestBase): def test_flatten(self): assert list(util.flatten_iterator([[1, 2, 3], [4, 5, 6], 7, @@ -253,7 +252,7 @@ class HashEqOverride(object): return True -class IdentitySetTest(TestBase): +class IdentitySetTest(fixtures.TestBase): def assert_eq(self, identityset, expected_iterable): expected = sorted([id(o) for o in expected_iterable]) found = sorted([id(o) for o in identityset]) @@ -370,7 +369,7 @@ class IdentitySetTest(TestBase): assert_raises(TypeError, lambda: s1 - os2) assert_raises(TypeError, lambda: s1 - [3, 4, 5]) -class OrderedIdentitySetTest(TestBase): +class OrderedIdentitySetTest(fixtures.TestBase): def assert_eq(self, identityset, expected_iterable): expected = [id(o) for o in expected_iterable] @@ -398,7 +397,7 @@ class OrderedIdentitySetTest(TestBase): eq_(s1.union(s2).intersection(s3), [a, d, f]) -class DictlikeIteritemsTest(TestBase): +class DictlikeIteritemsTest(fixtures.TestBase): baseline = set([('a', 1), ('b', 2), ('c', 3)]) def _ok(self, instance): @@ -475,7 +474,7 @@ class DictlikeIteritemsTest(TestBase): self._notok(duck6()) -class DuckTypeCollectionTest(TestBase): +class DuckTypeCollectionTest(fixtures.TestBase): def test_sets(self): # Py2K import sets @@ -506,7 +505,7 @@ class DuckTypeCollectionTest(TestBase): instance = type_() is_(util.duck_type_collection(instance), None) -class ArgInspectionTest(TestBase): +class ArgInspectionTest(fixtures.TestBase): def test_get_cls_kwargs(self): class A(object): def __init__(self, a): @@ -573,7 +572,7 @@ class ArgInspectionTest(TestBase): test(f3) test(f4) -class SymbolTest(TestBase): +class SymbolTest(fixtures.TestBase): def test_basic(self): sym1 = util.symbol('foo') assert sym1.name == 'foo' @@ -603,7 +602,7 @@ class SymbolTest(TestBase): assert rt is sym1 assert rt is sym2 -class WeakIdentityMappingTest(TestBase): +class WeakIdentityMappingTest(fixtures.TestBase): class Data(object): pass @@ -796,7 +795,7 @@ class WeakIdentityMappingTest(TestBase): eq_(wim._weakrefs, {}) -class TestFormatArgspec(TestBase): +class TestFormatArgspec(fixtures.TestBase): def test_specs(self): def test(fn, wanted, grouped=None): if grouped is None: @@ -937,7 +936,7 @@ class TestFormatArgspec(TestBase): test(O.__init__, custom_spec) -class AsInterfaceTest(TestBase): +class AsInterfaceTest(fixtures.TestBase): class Something(object): def _ignoreme(self): pass @@ -1026,7 +1025,7 @@ class AsInterfaceTest(TestBase): cls=self.Something) -class TestClassHierarchy(TestBase): +class TestClassHierarchy(fixtures.TestBase): def test_object(self): eq_(set(util.class_hierarchy(object)), set((object,))) @@ -1063,7 +1062,7 @@ class TestClassHierarchy(TestBase): # end Py2K -class TestClassProperty(TestBase): +class TestClassProperty(fixtures.TestBase): def test_simple(self): class A(object): diff --git a/test/bootstrap/noseplugin.py b/test/bootstrap/noseplugin.py index 0303c84dba..a0e3b5ea36 100644 --- a/test/bootstrap/noseplugin.py +++ b/test/bootstrap/noseplugin.py @@ -87,8 +87,8 @@ class NoseSQLAlchemy(Plugin): fn(self.options, file_config) def begin(self): - global testing, requires, util - from test.lib import testing, requires + global testing, requires, util, fixtures + from test.lib import testing, requires, fixtures from sqlalchemy import util testing.db = db @@ -117,7 +117,7 @@ class NoseSQLAlchemy(Plugin): """ - if not issubclass(cls, testing.TestBase): + if not issubclass(cls, fixtures.TestBase): return False else: if (hasattr(cls, '__whitelist__') and testing.db.name in cls.__whitelist__): diff --git a/test/dialect/test_access.py b/test/dialect/test_access.py index bd0d7c22ac..e2c20804f0 100644 --- a/test/dialect/test_access.py +++ b/test/dialect/test_access.py @@ -4,7 +4,7 @@ from sqlalchemy.databases import access from test.lib import * -class CompileTest(TestBase, AssertsCompiledSQL): +class CompileTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = access.dialect() def test_extract(self): diff --git a/test/dialect/test_firebird.py b/test/dialect/test_firebird.py index 430b85d181..3241db730a 100644 --- a/test/dialect/test_firebird.py +++ b/test/dialect/test_firebird.py @@ -6,7 +6,7 @@ from sqlalchemy.sql import table, column from test.lib import * -class DomainReflectionTest(TestBase, AssertsExecutionResults): +class DomainReflectionTest(fixtures.TestBase, AssertsExecutionResults): "Test Firebird domains" __only_on__ = 'firebird' @@ -93,7 +93,7 @@ class DomainReflectionTest(TestBase, AssertsExecutionResults): assert isinstance(table.c.dt.type, DateTime) -class BuggyDomainReflectionTest(TestBase, AssertsExecutionResults): +class BuggyDomainReflectionTest(fixtures.TestBase, AssertsExecutionResults): """Test Firebird domains (and some other reflection bumps), see [ticket:1663] and http://tracker.firebirdsql.org/browse/CORE-356""" @@ -231,7 +231,7 @@ ID DOM_ID /* INTEGER NOT NULL */ default 0 ) eq_(table_b.c.id.server_default.arg.text, "0") -class CompileTest(TestBase, AssertsCompiledSQL): +class CompileTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = firebird.FBDialect() @@ -319,7 +319,7 @@ class CompileTest(TestBase, AssertsCompiledSQL): for type_, args, kw, res in columns: self.assert_compile(type_(*args, **kw), res) -class TypesTest(TestBase): +class TypesTest(fixtures.TestBase): __only_on__ = 'firebird' @testing.provide_metadata @@ -334,7 +334,7 @@ class TypesTest(TestBase): [(float('inf'),)] ) -class MiscTest(TestBase): +class MiscTest(fixtures.TestBase): __only_on__ = 'firebird' diff --git a/test/dialect/test_informix.py b/test/dialect/test_informix.py index ea74dcbe4e..3fa2f04700 100644 --- a/test/dialect/test_informix.py +++ b/test/dialect/test_informix.py @@ -3,7 +3,7 @@ from sqlalchemy.databases import informix from test.lib import * -class CompileTest(TestBase, AssertsCompiledSQL): +class CompileTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = informix.InformixDialect() diff --git a/test/dialect/test_maxdb.py b/test/dialect/test_maxdb.py index 6ed420d5c4..8d76529d78 100644 --- a/test/dialect/test_maxdb.py +++ b/test/dialect/test_maxdb.py @@ -16,7 +16,7 @@ from test.lib import * # - datetime tests # - the orm/query 'test_has' destabilizes the server- cover here -class ReflectionTest(TestBase, AssertsExecutionResults): +class ReflectionTest(fixtures.TestBase, AssertsExecutionResults): """Extra reflection tests.""" __only_on__ = 'maxdb' @@ -169,7 +169,7 @@ class ReflectionTest(TestBase, AssertsExecutionResults): except exc.DatabaseError: pass -class DBAPITest(TestBase, AssertsExecutionResults): +class DBAPITest(fixtures.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/test_mssql.py b/test/dialect/test_mssql.py index 3e3690c123..0e1745bcf4 100644 --- a/test/dialect/test_mssql.py +++ b/test/dialect/test_mssql.py @@ -17,7 +17,7 @@ from test.lib.testing import eq_, emits_warning_on, \ from sqlalchemy.util.compat import decimal from sqlalchemy.engine.reflection import Inspector -class CompileTest(TestBase, AssertsCompiledSQL): +class CompileTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = mssql.dialect() def test_insert(self): @@ -379,7 +379,7 @@ class CompileTest(TestBase, AssertsCompiledSQL): -class IdentityInsertTest(TestBase, AssertsCompiledSQL): +class IdentityInsertTest(fixtures.TestBase, AssertsCompiledSQL): __only_on__ = 'mssql' __dialect__ = mssql.MSDialect() @@ -432,7 +432,7 @@ class IdentityInsertTest(TestBase, AssertsCompiledSQL): eq_([(91, 'Smalltalk'), (90, 'PHP')], list(lastcats)) -class ReflectionTest(TestBase, ComparesTables): +class ReflectionTest(fixtures.TestBase, ComparesTables): __only_on__ = 'mssql' def test_basic_reflection(self): @@ -562,7 +562,7 @@ class ReflectionTest(TestBase, ComparesTables): set([t2.c['x col'], t2.c.y]) ) -class QueryUnicodeTest(TestBase): +class QueryUnicodeTest(fixtures.TestBase): __only_on__ = 'mssql' @@ -587,7 +587,7 @@ class QueryUnicodeTest(TestBase): finally: meta.drop_all() -class QueryTest(TestBase): +class QueryTest(fixtures.TestBase): __only_on__ = 'mssql' def test_fetchid_trigger(self): @@ -719,7 +719,7 @@ class Foo(object): for k in kw: setattr(self, k, kw[k]) -class GenerativeQueryTest(TestBase): +class GenerativeQueryTest(fixtures.TestBase): __only_on__ = 'mssql' @classmethod @@ -753,7 +753,7 @@ class GenerativeQueryTest(TestBase): assert list(query[:10]) == orig[:10] -class SchemaTest(TestBase): +class SchemaTest(fixtures.TestBase): def setup(self): t = Table('sometable', MetaData(), @@ -800,7 +800,7 @@ def full_text_search_missing(): finally: connection.close() -class MatchTest(TestBase, AssertsCompiledSQL): +class MatchTest(fixtures.TestBase, AssertsCompiledSQL): __only_on__ = 'mssql' __skip_if__ = full_text_search_missing, @@ -914,7 +914,7 @@ class MatchTest(TestBase, AssertsCompiledSQL): eq_([1, 3, 5], [r.id for r in results]) -class ParseConnectTest(TestBase, AssertsCompiledSQL): +class ParseConnectTest(fixtures.TestBase, AssertsCompiledSQL): @classmethod def setup_class(cls): global dialect @@ -1036,7 +1036,7 @@ class ParseConnectTest(TestBase, AssertsCompiledSQL): 'Unrecognized server version info', engine.connect) -class TypesTest(TestBase, AssertsExecutionResults, ComparesTables): +class TypesTest(fixtures.TestBase, AssertsExecutionResults, ComparesTables): __only_on__ = 'mssql' @classmethod @@ -1567,7 +1567,7 @@ class TypesTest(TestBase, AssertsExecutionResults, ComparesTables): not in list(engine.execute(tbl.select()).first()) engine.execute(tbl.delete()) -class BinaryTest(TestBase, AssertsExecutionResults): +class BinaryTest(fixtures.TestBase, AssertsExecutionResults): """Test the Binary and VarBinary types""" __only_on__ = 'mssql' @@ -1672,7 +1672,7 @@ class BinaryTest(TestBase, AssertsExecutionResults): return stream -class ReflectHugeViewTest(TestBase): +class ReflectHugeViewTest(fixtures.TestBase): __only_on__ = 'mssql' def setup(self): diff --git a/test/dialect/test_mxodbc.py b/test/dialect/test_mxodbc.py index 58ceaf91c1..78f8ba6982 100644 --- a/test/dialect/test_mxodbc.py +++ b/test/dialect/test_mxodbc.py @@ -1,6 +1,7 @@ from sqlalchemy import * -from test.lib.testing import eq_, TestBase +from test.lib.testing import eq_ from test.lib import engines +from test.lib import fixtures # TODO: we should probably build mock bases for # these to share with test_reconnect, test_parseconnect @@ -35,7 +36,7 @@ class MockCursor(object): def close(self): pass -class MxODBCTest(TestBase): +class MxODBCTest(fixtures.TestBase): def test_native_odbc_execute(self): t1 = Table('t1', MetaData(), Column('c1', Integer)) diff --git a/test/dialect/test_mysql.py b/test/dialect/test_mysql.py index 2653ae00fb..fb20f44fdd 100644 --- a/test/dialect/test_mysql.py +++ b/test/dialect/test_mysql.py @@ -16,7 +16,7 @@ from test.lib import * from test.lib.engines import utf8_engine import datetime -class CompileTest(TestBase, AssertsCompiledSQL): +class CompileTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = mysql.dialect() @@ -29,7 +29,7 @@ class CompileTest(TestBase, AssertsCompiledSQL): self.assert_compile(x, '''SELECT mysql_table.col1, mysql_table.`master_ssl_verify_server_cert` FROM mysql_table''') -class DialectTest(TestBase): +class DialectTest(fixtures.TestBase): __only_on__ = 'mysql' @testing.only_on(['mysql+mysqldb', 'mysql+oursql'], @@ -54,7 +54,7 @@ class DialectTest(TestBase): } ) -class TypesTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL): +class TypesTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): "Test MySQL column types" __only_on__ = 'mysql' @@ -783,7 +783,7 @@ class TypesTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL): finally: enum_table.drop() -class ReflectionTest(TestBase, AssertsExecutionResults): +class ReflectionTest(fixtures.TestBase, AssertsExecutionResults): __only_on__ = 'mysql' @@ -1045,7 +1045,7 @@ class ReflectionTest(TestBase, AssertsExecutionResults): -class SQLTest(TestBase, AssertsCompiledSQL): +class SQLTest(fixtures.TestBase, AssertsCompiledSQL): """Tests MySQL-dialect specific compilation.""" __dialect__ = mysql.dialect() @@ -1333,7 +1333,7 @@ class SQLTest(TestBase, AssertsCompiledSQL): 'INTEGER NOT NULL, PRIMARY KEY ' '(assigned_id, id))ENGINE=InnoDB') -class SQLModeDetectionTest(TestBase): +class SQLModeDetectionTest(fixtures.TestBase): __only_on__ = 'mysql' def _options(self, modes): @@ -1377,7 +1377,7 @@ class SQLModeDetectionTest(TestBase): c.close() engine.dispose() -class RawReflectionTest(TestBase): +class RawReflectionTest(fixtures.TestBase): def setup(self): dialect = mysql.dialect() self.parser = mysql.MySQLTableDefinitionParser(dialect, dialect.identifier_preparer) @@ -1393,7 +1393,7 @@ class RawReflectionTest(TestBase): assert regex.match(' PRIMARY KEY (`id`) USING BTREE') -class ExecutionTest(TestBase): +class ExecutionTest(fixtures.TestBase): """Various MySQL execution special cases.""" __only_on__ = 'mysql' @@ -1413,7 +1413,7 @@ class ExecutionTest(TestBase): d = testing.db.scalar(func.sysdate()) assert isinstance(d, datetime.datetime) -class MatchTest(TestBase, AssertsCompiledSQL): +class MatchTest(fixtures.TestBase, AssertsCompiledSQL): __only_on__ = 'mysql' @classmethod diff --git a/test/dialect/test_oracle.py b/test/dialect/test_oracle.py index a3fd69a259..913170699e 100644 --- a/test/dialect/test_oracle.py +++ b/test/dialect/test_oracle.py @@ -15,7 +15,7 @@ import datetime import os -class OutParamTest(TestBase, AssertsExecutionResults): +class OutParamTest(fixtures.TestBase, AssertsExecutionResults): __only_on__ = 'oracle+cx_oracle' @classmethod @@ -48,7 +48,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(TestBase, AssertsCompiledSQL): +class CompileTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = oracle.OracleDialect() @@ -373,7 +373,7 @@ class CompileTest(TestBase, AssertsCompiledSQL): ]: self.assert_compile(fn, expected) -class CompatFlagsTest(TestBase, AssertsCompiledSQL): +class CompatFlagsTest(fixtures.TestBase, AssertsCompiledSQL): __only_on__ = 'oracle' def test_ora8_flags(self): @@ -428,7 +428,7 @@ class CompatFlagsTest(TestBase, AssertsCompiledSQL): self.assert_compile(UnicodeText(),"NCLOB",dialect=dialect) -class MultiSchemaTest(TestBase, AssertsCompiledSQL): +class MultiSchemaTest(fixtures.TestBase, AssertsCompiledSQL): __only_on__ = 'oracle' @classmethod @@ -586,7 +586,7 @@ drop synonym test_schema.ptable; select([parent, child]).select_from(parent.join(child)).execute().fetchall() -class ConstraintTest(TestBase): +class ConstraintTest(fixtures.TestBase): __only_on__ = 'oracle' @@ -611,7 +611,7 @@ class ConstraintTest(TestBase): onupdate='CASCADE')) assert_raises(exc.SAWarning, bat.create) -class TypesTest(TestBase, AssertsCompiledSQL): +class TypesTest(fixtures.TestBase, AssertsCompiledSQL): __only_on__ = 'oracle' __dialect__ = oracle.OracleDialect() @@ -1059,7 +1059,7 @@ class TypesTest(TestBase, AssertsCompiledSQL): finally: t.drop(engine) -class EuroNumericTest(TestBase): +class EuroNumericTest(fixtures.TestBase): """test the numeric output_type_handler when using non-US locale for NLS_LANG.""" __only_on__ = 'oracle+cx_oracle' @@ -1094,7 +1094,7 @@ class EuroNumericTest(TestBase): assert type(test_exp) is type(exp) -class DontReflectIOTTest(TestBase): +class DontReflectIOTTest(fixtures.TestBase): """test that index overflow tables aren't included in table_names.""" @@ -1125,7 +1125,7 @@ class DontReflectIOTTest(TestBase): set(['admin_docindex']) ) -class BufferedColumnTest(TestBase, AssertsCompiledSQL): +class BufferedColumnTest(fixtures.TestBase, AssertsCompiledSQL): __only_on__ = 'oracle' @classmethod @@ -1159,7 +1159,7 @@ class BufferedColumnTest(TestBase, AssertsCompiledSQL): result = eng.execute(binary_table.select()).fetchall() eq_(result, [(i, stream) for i in range(1, 11)]) -class UnsupportedIndexReflectTest(TestBase): +class UnsupportedIndexReflectTest(fixtures.TestBase): __only_on__ = 'oracle' def setup(self): @@ -1179,7 +1179,7 @@ class UnsupportedIndexReflectTest(TestBase): m2 = MetaData(testing.db) t2 = Table('test_index_reflect', m2, autoload=True) -class RoundTripIndexTest(TestBase): +class RoundTripIndexTest(fixtures.TestBase): __only_on__ = 'oracle' def test_basic(self): @@ -1253,7 +1253,7 @@ class RoundTripIndexTest(TestBase): -class SequenceTest(TestBase, AssertsCompiledSQL): +class SequenceTest(fixtures.TestBase, AssertsCompiledSQL): def test_basic(self): seq = Sequence('my_seq_no_schema') @@ -1268,7 +1268,7 @@ class SequenceTest(TestBase, AssertsCompiledSQL): == '"Some_Schema"."My_Seq"' -class ExecuteTest(TestBase): +class ExecuteTest(fixtures.TestBase): __only_on__ = 'oracle' diff --git a/test/dialect/test_postgresql.py b/test/dialect/test_postgresql.py index 956fc9ebcb..e276e5931c 100644 --- a/test/dialect/test_postgresql.py +++ b/test/dialect/test_postgresql.py @@ -12,10 +12,9 @@ from test.lib import * from test.lib.util import round_decimal from sqlalchemy.sql import table, column from test.lib.testing import eq_ -from test.engine._base import TablesTest import logging -class SequenceTest(TestBase, AssertsCompiledSQL): +class SequenceTest(fixtures.TestBase, AssertsCompiledSQL): def test_format(self): seq = Sequence('my_seq_no_schema') @@ -48,7 +47,7 @@ class SequenceTest(TestBase, AssertsCompiledSQL): r = engine.execute(t.insert()) assert r.inserted_primary_key == [1] -class CompileTest(TestBase, AssertsCompiledSQL): +class CompileTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = postgresql.dialect() @@ -231,7 +230,7 @@ class CompileTest(TestBase, AssertsCompiledSQL): '''SELECT pg_table.col1, pg_table."variadic" FROM pg_table''') -class FloatCoercionTest(TablesTest, AssertsExecutionResults): +class FloatCoercionTest(fixtures.TablesTest, AssertsExecutionResults): __only_on__ = 'postgresql' __dialect__ = postgresql.dialect() @@ -300,7 +299,7 @@ class FloatCoercionTest(TablesTest, AssertsExecutionResults): ([5], [5], [6], [decimal.Decimal("6.4")]) ) -class EnumTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL): +class EnumTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): __only_on__ = 'postgresql' __dialect__ = postgresql.dialect() @@ -507,7 +506,7 @@ class EnumTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL): finally: metadata.drop_all() -class NumericInterpretationTest(TestBase): +class NumericInterpretationTest(fixtures.TestBase): __only_on__ = 'postgresql' def test_numeric_codes(self): @@ -550,7 +549,7 @@ class NumericInterpretationTest(TestBase): (1, decimal.Decimal("1"), 1, decimal.Decimal("1"), 1) ) -class InsertTest(TestBase, AssertsExecutionResults): +class InsertTest(fixtures.TestBase, AssertsExecutionResults): __only_on__ = 'postgresql' @@ -991,7 +990,7 @@ class InsertTest(TestBase, AssertsExecutionResults): assert table.select().execute().fetchall() == [(30, 'd1'), (31, 'd2'), (32, 'd3'), (33, 'd4')] -class DomainReflectionTest(TestBase, AssertsExecutionResults): +class DomainReflectionTest(fixtures.TestBase, AssertsExecutionResults): """Test PostgreSQL domains""" @@ -1099,7 +1098,7 @@ class DomainReflectionTest(TestBase, AssertsExecutionResults): finally: postgresql.PGDialect.ischema_names = ischema_names -class DistinctOnTest(TestBase, AssertsCompiledSQL): +class DistinctOnTest(fixtures.TestBase, AssertsCompiledSQL): """Test 'DISTINCT' with SQL expression language and orm.Query with an emphasis on PG's 'DISTINCT ON' syntax. @@ -1204,7 +1203,7 @@ class DistinctOnTest(TestBase, AssertsCompiledSQL): "t_1.a AS t_1_a, t_1.b AS t_1_b FROM t AS t_1" ) -class MiscTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL): +class MiscTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): __only_on__ = 'postgresql' @@ -1530,7 +1529,7 @@ class MiscTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL): "c %s NOT NULL" % expected ) -class TimezoneTest(TestBase): +class TimezoneTest(fixtures.TestBase): """Test timezone-aware datetimes. @@ -1605,7 +1604,7 @@ class TimezoneTest(TestBase): row = result.first() assert row[0] >= somedate -class TimePrecisionTest(TestBase, AssertsCompiledSQL): +class TimePrecisionTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = postgresql.dialect() @@ -1655,7 +1654,7 @@ class TimePrecisionTest(TestBase, AssertsCompiledSQL): eq_(t2.c.c5.type.timezone, False) eq_(t2.c.c6.type.timezone, True) -class ArrayTest(TestBase, AssertsExecutionResults): +class ArrayTest(fixtures.TestBase, AssertsExecutionResults): __only_on__ = 'postgresql' @@ -1819,7 +1818,7 @@ class ArrayTest(TestBase, AssertsExecutionResults): -class TimestampTest(TestBase, AssertsExecutionResults): +class TimestampTest(fixtures.TestBase, AssertsExecutionResults): __only_on__ = 'postgresql' def test_timestamp(self): @@ -1830,7 +1829,7 @@ class TimestampTest(TestBase, AssertsExecutionResults): result = connection.execute(s).first() eq_(result[0], datetime.datetime(2007, 12, 25, 0, 0)) -class ServerSideCursorsTest(TestBase, AssertsExecutionResults): +class ServerSideCursorsTest(fixtures.TestBase, AssertsExecutionResults): __only_on__ = 'postgresql+psycopg2' @@ -1973,7 +1972,7 @@ class ServerSideCursorsTest(TestBase, AssertsExecutionResults): finally: test_table.drop(checkfirst=True) -class SpecialTypesTest(TestBase, ComparesTables, AssertsCompiledSQL): +class SpecialTypesTest(fixtures.TestBase, ComparesTables, AssertsCompiledSQL): """test DDL and reflection of PG-specific types """ __only_on__ = 'postgresql' @@ -2058,7 +2057,7 @@ class SpecialTypesTest(TestBase, ComparesTables, AssertsCompiledSQL): eq_(t2.c.bitvarying5.type.length, 5) eq_(t2.c.bitvarying5.type.varying, True) -class UUIDTest(TestBase): +class UUIDTest(fixtures.TestBase): """Test the bind/return values of the UUID type.""" __only_on__ = 'postgresql' @@ -2118,7 +2117,7 @@ class UUIDTest(TestBase): eq_(r.fetchone(), None) -class MatchTest(TestBase, AssertsCompiledSQL): +class MatchTest(fixtures.TestBase, AssertsCompiledSQL): __only_on__ = 'postgresql' __excluded_on__ = ('postgresql', '<', (8, 3, 0)), @@ -2222,7 +2221,7 @@ class MatchTest(TestBase, AssertsCompiledSQL): eq_([1, 3, 5], [r.id for r in results]) -class TupleTest(TestBase): +class TupleTest(fixtures.TestBase): __only_on__ = 'postgresql' def test_tuple_containment(self): diff --git a/test/dialect/test_sqlite.py b/test/dialect/test_sqlite.py index fb98d2f0a1..991700e94d 100644 --- a/test/dialect/test_sqlite.py +++ b/test/dialect/test_sqlite.py @@ -11,7 +11,7 @@ from sqlalchemy.engine.url import make_url from test.lib import * import os -class TestTypes(TestBase, AssertsExecutionResults): +class TestTypes(fixtures.TestBase, AssertsExecutionResults): __only_on__ = 'sqlite' @@ -168,7 +168,7 @@ class TestTypes(TestBase, AssertsExecutionResults): assert isinstance(t2.c.y.type, sqltypes.NullType) -class TestDefaults(TestBase, AssertsExecutionResults): +class TestDefaults(fixtures.TestBase, AssertsExecutionResults): __only_on__ = 'sqlite' @@ -220,7 +220,7 @@ class TestDefaults(TestBase, AssertsExecutionResults): db.execute('DROP TABLE r_defaults') -class DialectTest(TestBase, AssertsExecutionResults): +class DialectTest(fixtures.TestBase, AssertsExecutionResults): __only_on__ = 'sqlite' @@ -375,7 +375,7 @@ class DialectTest(TestBase, AssertsExecutionResults): meta.drop_all() -class SQLTest(TestBase, AssertsCompiledSQL): +class SQLTest(fixtures.TestBase, AssertsCompiledSQL): """Tests SQLite-dialect specific compilation.""" @@ -452,7 +452,7 @@ class SQLTest(TestBase, AssertsCompiledSQL): ) -class InsertTest(TestBase, AssertsExecutionResults): +class InsertTest(fixtures.TestBase, AssertsExecutionResults): """Tests inserts and autoincrement.""" @@ -535,7 +535,7 @@ def full_text_search_missing(): return True -class MatchTest(TestBase, AssertsCompiledSQL): +class MatchTest(fixtures.TestBase, AssertsCompiledSQL): __only_on__ = 'sqlite' __skip_if__ = full_text_search_missing, @@ -618,7 +618,7 @@ class MatchTest(TestBase, AssertsCompiledSQL): eq_([1, 3], [r.id for r in results]) -class AutoIncrementTest(TestBase, AssertsCompiledSQL): +class AutoIncrementTest(fixtures.TestBase, AssertsCompiledSQL): def test_sqlite_autoincrement(self): table = Table('autoinctable', MetaData(), Column('id', Integer, diff --git a/test/dialect/test_sybase.py b/test/dialect/test_sybase.py index 54e4f32e1e..0a7cbf6b6d 100644 --- a/test/dialect/test_sybase.py +++ b/test/dialect/test_sybase.py @@ -4,7 +4,7 @@ from sqlalchemy.databases import sybase from test.lib import * -class CompileTest(TestBase, AssertsCompiledSQL): +class CompileTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = sybase.dialect() def test_extract(self): diff --git a/test/engine/test_bind.py b/test/engine/test_bind.py index 0ef70c2448..0d7b7d6930 100644 --- a/test/engine/test_bind.py +++ b/test/engine/test_bind.py @@ -9,9 +9,9 @@ from test.lib.schema import Table from test.lib.schema import Column import sqlalchemy as sa from test.lib import testing +from test.lib import fixtures - -class BindTest(testing.TestBase): +class BindTest(fixtures.TestBase): def test_create_drop_explicit(self): metadata = MetaData() table = Table('test_table', metadata, diff --git a/test/engine/test_ddlevents.py b/test/engine/test_ddlevents.py index 42dc804a5b..536325d880 100644 --- a/test/engine/test_ddlevents.py +++ b/test/engine/test_ddlevents.py @@ -6,11 +6,13 @@ from sqlalchemy import MetaData, Integer, String, event, exc, text from test.lib.schema import Table from test.lib.schema import Column import sqlalchemy as tsa -from test.lib import TestBase, testing, engines +from test.lib import testing, engines from test.lib.testing import AssertsCompiledSQL, eq_ from nose import SkipTest +from test.lib import fixtures -class DDLEventTest(TestBase): + +class DDLEventTest(fixtures.TestBase): class Canary(object): def __init__(self, schema_item, bind): self.state = None @@ -185,7 +187,7 @@ class DDLEventTest(TestBase): 'blah', fn) -class DDLExecutionTest(TestBase): +class DDLExecutionTest(fixtures.TestBase): def setup(self): self.engine = engines.mock_engine() self.metadata = MetaData(self.engine) @@ -427,7 +429,7 @@ class DDLExecutionTest(TestBase): -class DDLTest(TestBase, AssertsCompiledSQL): +class DDLTest(fixtures.TestBase, AssertsCompiledSQL): def mock_engine(self): executor = lambda *a, **kw: None engine = create_engine(testing.db.name + '://', diff --git a/test/engine/test_execute.py b/test/engine/test_execute.py index f70d565278..35a3c36c9f 100644 --- a/test/engine/test_execute.py +++ b/test/engine/test_execute.py @@ -6,14 +6,15 @@ from sqlalchemy import MetaData, Integer, String, INT, VARCHAR, func, \ from sqlalchemy.sql import column, literal from test.lib.schema import Table, Column import sqlalchemy as tsa -from test.lib import TestBase, testing, engines +from test.lib import testing, engines import logging from sqlalchemy.dialects.oracle.zxjdbc import ReturningParam from sqlalchemy.engine import base, default from sqlalchemy.engine.base import Connection, Engine +from test.lib import fixtures users, metadata = None, None -class ExecuteTest(TestBase): +class ExecuteTest(fixtures.TestBase): @classmethod def setup_class(cls): global users, users_autoinc, metadata @@ -174,7 +175,7 @@ class ExecuteTest(TestBase): eq_(conn._execution_options['foo'], 'hoho') -class CompiledCacheTest(TestBase): +class CompiledCacheTest(fixtures.TestBase): @classmethod def setup_class(cls): global users, metadata @@ -206,7 +207,7 @@ class CompiledCacheTest(TestBase): assert len(cache) == 1 eq_(conn.execute("select count(*) from users").scalar(), 3) -class LoggingNameTest(TestBase): +class LoggingNameTest(fixtures.TestBase): def _assert_names_in_execute(self, eng, eng_name, pool_name): eng.execute(select([1])) for name in [b.name for b in self.buf.buffer]: @@ -289,7 +290,7 @@ class LoggingNameTest(TestBase): eng = self._unnamed_engine(echo='debug', echo_pool='debug') self._assert_no_name_in_execute(eng) -class EchoTest(TestBase): +class EchoTest(fixtures.TestBase): def setup(self): self.level = logging.getLogger('sqlalchemy.engine').level @@ -359,7 +360,7 @@ class EchoTest(TestBase): assert self.buf.buffer[2].getMessage().startswith("SELECT 6") assert len(self.buf.buffer) == 4 -class ResultProxyTest(TestBase): +class ResultProxyTest(fixtures.TestBase): def test_nontuple_row(self): """ensure the C version of BaseRowProxy handles duck-type-dependent rows.""" @@ -454,7 +455,7 @@ class ResultProxyTest(TestBase): writer.writerow(row) assert s.getvalue().strip() == '1,Test' -class AlternateResultProxyTest(TestBase): +class AlternateResultProxyTest(fixtures.TestBase): __requires__ = ('sqlite', ) @classmethod @@ -515,7 +516,7 @@ class AlternateResultProxyTest(TestBase): def test_buffered_column_result_proxy(self): self._test_proxy(base.BufferedColumnResultProxy) -class EngineEventsTest(TestBase): +class EngineEventsTest(fixtures.TestBase): def tearDown(self): Engine.dispatch._clear() @@ -776,7 +777,7 @@ class EngineEventsTest(TestBase): ) -class ProxyConnectionTest(TestBase): +class ProxyConnectionTest(fixtures.TestBase): """These are the same tests as EngineEventsTest, except using the deprecated ConnectionProxy interface. diff --git a/test/engine/test_parseconnect.py b/test/engine/test_parseconnect.py index f80bf30455..3b3e09a7ad 100644 --- a/test/engine/test_parseconnect.py +++ b/test/engine/test_parseconnect.py @@ -5,10 +5,9 @@ import sqlalchemy.engine.url as url from sqlalchemy import create_engine, engine_from_config, exc from sqlalchemy.engine import _coerce_config import sqlalchemy as tsa -from test.lib import TestBase +from test.lib import fixtures - -class ParseConnectTest(TestBase): +class ParseConnectTest(fixtures.TestBase): def test_rfc1738(self): for text in ( 'dbtype://username:password@hostspec:110//usr/db_file.db', @@ -40,7 +39,7 @@ class ParseConnectTest(TestBase): or not u.host assert str(u) == text -class DialectImportTest(TestBase): +class DialectImportTest(fixtures.TestBase): def test_import_base_dialects(self): # the globals() somehow makes it for the exec() + nose3. @@ -57,7 +56,7 @@ class DialectImportTest(TestBase): '%s.dialect()' % (name, name), globals()) eq_(dialect.name, name) -class CreateEngineTest(TestBase): +class CreateEngineTest(fixtures.TestBase): """test that create_engine arguments of different types get propagated properly""" diff --git a/test/engine/test_pool.py b/test/engine/test_pool.py index d0c7ca7b94..f5660b9d6b 100644 --- a/test/engine/test_pool.py +++ b/test/engine/test_pool.py @@ -1,9 +1,10 @@ import threading, time from sqlalchemy import pool, interfaces, create_engine, select, event import sqlalchemy as tsa -from test.lib import TestBase, testing +from test.lib import testing from test.lib.util import gc_collect, lazy_gc from test.lib.testing import eq_, assert_raises +from test.lib import fixtures mcid = 1 class MockDBAPI(object): @@ -33,7 +34,7 @@ class MockCursor(object): def close(self): pass -class PoolTestBase(TestBase): +class PoolTestBase(fixtures.TestBase): def setup(self): pool.clear_managers() diff --git a/test/engine/test_reconnect.py b/test/engine/test_reconnect.py index 74986c1784..44fb4f93bc 100644 --- a/test/engine/test_reconnect.py +++ b/test/engine/test_reconnect.py @@ -4,9 +4,10 @@ import weakref from sqlalchemy import select, MetaData, Integer, String, pool from test.lib.schema import Table, Column import sqlalchemy as tsa -from test.lib import TestBase, testing, engines +from test.lib import testing, engines from test.lib.util import gc_collect from sqlalchemy import exc +from test.lib import fixtures class MockDisconnect(Exception): pass @@ -48,7 +49,7 @@ class MockCursor(object): pass db, dbapi = None, None -class MockReconnectTest(TestBase): +class MockReconnectTest(fixtures.TestBase): def setup(self): global db, dbapi dbapi = MockDBAPI() @@ -178,7 +179,7 @@ class MockReconnectTest(TestBase): assert not conn.invalidated assert len(dbapi.connections) == 1 -class CursorErrTest(TestBase): +class CursorErrTest(fixtures.TestBase): def setup(self): global db, dbapi @@ -211,7 +212,7 @@ class CursorErrTest(TestBase): db.dispose() engine = None -class RealReconnectTest(TestBase): +class RealReconnectTest(fixtures.TestBase): def setup(self): global engine engine = engines.reconnecting_engine() @@ -383,7 +384,7 @@ class RealReconnectTest(TestBase): eq_(conn.execute(select([1])).scalar(), 1) assert not conn.invalidated -class RecycleTest(TestBase): +class RecycleTest(fixtures.TestBase): def test_basic(self): for threadlocal in False, True: @@ -414,7 +415,7 @@ class RecycleTest(TestBase): conn.close() meta, table, engine = None, None, None -class InvalidateDuringResultTest(TestBase): +class InvalidateDuringResultTest(fixtures.TestBase): def setup(self): global meta, table, engine engine = engines.reconnecting_engine() diff --git a/test/engine/test_reflection.py b/test/engine/test_reflection.py index 8c806e39ae..8048f602ec 100644 --- a/test/engine/test_reflection.py +++ b/test/engine/test_reflection.py @@ -6,14 +6,15 @@ from sqlalchemy.engine.reflection import Inspector from sqlalchemy import MetaData from test.lib.schema import Table, Column import sqlalchemy as sa -from test.lib import TestBase, ComparesTables, \ +from test.lib import ComparesTables, \ testing, engines, AssertsCompiledSQL +from test.lib import fixtures create_inspector = Inspector.from_engine metadata, users = None, None -class ReflectionTest(TestBase, ComparesTables): +class ReflectionTest(fixtures.TestBase, ComparesTables): @testing.exclude('mssql', '<', (10, 0, 0), 'Date is only supported on MSSQL 2008+') @@ -810,7 +811,7 @@ class ReflectionTest(TestBase, ComparesTables): finally: _drop_views(metadata.bind) -class CreateDropTest(TestBase): +class CreateDropTest(fixtures.TestBase): @classmethod def setup_class(cls): @@ -895,7 +896,7 @@ class CreateDropTest(TestBase): - set(testing.db.table_names())) metadata.drop_all(bind=testing.db) -class SchemaManipulationTest(TestBase): +class SchemaManipulationTest(fixtures.TestBase): def test_append_constraint_unique(self): meta = MetaData() @@ -911,7 +912,7 @@ class SchemaManipulationTest(TestBase): assert len(addresses.c.user_id.foreign_keys) == 1 assert addresses.constraints == set([addresses.primary_key, fk]) -class UnicodeReflectionTest(TestBase): +class UnicodeReflectionTest(fixtures.TestBase): @testing.requires.unicode_connections def test_basic(self): @@ -961,7 +962,7 @@ class UnicodeReflectionTest(TestBase): bind.dispose() -class SchemaTest(TestBase): +class SchemaTest(fixtures.TestBase): def test_iteration(self): metadata = MetaData() @@ -1023,7 +1024,7 @@ class SchemaTest(TestBase): metadata.drop_all() -class HasSequenceTest(TestBase): +class HasSequenceTest(fixtures.TestBase): @testing.requires.sequences def test_has_sequence(self): @@ -1135,7 +1136,7 @@ def _drop_views(con, schema=None): con.execute(sa.sql.text(query)) -class ReverseCasingReflectTest(TestBase, AssertsCompiledSQL): +class ReverseCasingReflectTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = 'default' @testing.requires.denormalized_names @@ -1161,7 +1162,7 @@ class ReverseCasingReflectTest(TestBase, AssertsCompiledSQL): 'weird_casing."Col2", weird_casing."col3" ' 'FROM weird_casing') -class ComponentReflectionTest(TestBase): +class ComponentReflectionTest(fixtures.TestBase): @testing.requires.schemas def test_get_schema_names(self): @@ -1433,7 +1434,7 @@ class ComponentReflectionTest(TestBase): def test_get_table_oid_with_schema(self): self._test_get_table_oid('users', schema='test_schema') -class ColumnEventsTest(TestBase): +class ColumnEventsTest(fixtures.TestBase): @classmethod def setup_class(cls): cls.metadata = MetaData() diff --git a/test/engine/test_transaction.py b/test/engine/test_transaction.py index 8e4aebff9f..d74df1d114 100644 --- a/test/engine/test_transaction.py +++ b/test/engine/test_transaction.py @@ -7,11 +7,12 @@ from sqlalchemy import create_engine, MetaData, INT, VARCHAR, Sequence, \ select, Integer, String, func, text, exc from test.lib.schema import Table from test.lib.schema import Column -from test.lib import TestBase, testing +from test.lib import testing +from test.lib import fixtures users, metadata = None, None -class TransactionTest(TestBase): +class TransactionTest(fixtures.TestBase): @classmethod def setup_class(cls): global users, metadata @@ -351,7 +352,7 @@ class TransactionTest(TestBase): eq_(result.fetchall(), [('user1', ), ('user4', )]) conn.close() -class AutoRollbackTest(TestBase): +class AutoRollbackTest(fixtures.TestBase): @classmethod def setup_class(cls): @@ -383,7 +384,7 @@ class AutoRollbackTest(TestBase): users.drop(conn2) conn2.close() -class ExplicitAutoCommitTest(TestBase): +class ExplicitAutoCommitTest(fixtures.TestBase): """test the 'autocommit' flag on select() and text() objects. @@ -515,7 +516,7 @@ class ExplicitAutoCommitTest(TestBase): tlengine = None -class TLTransactionTest(TestBase): +class TLTransactionTest(fixtures.TestBase): @classmethod def setup_class(cls): @@ -959,7 +960,7 @@ class TLTransactionTest(TestBase): counters = None -class ForUpdateTest(TestBase): +class ForUpdateTest(fixtures.TestBase): @classmethod def setup_class(cls): @@ -1110,7 +1111,7 @@ class ForUpdateTest(TestBase): update_style='nowait') self.assert_(len(errors) != 0) -class IsolationLevelTest(TestBase): +class IsolationLevelTest(fixtures.TestBase): __requires__ = ('isolation_level',) def _default_isolation_level(self): diff --git a/test/ex/test_examples.py b/test/ex/test_examples.py index 311eab0413..ce44067fe4 100644 --- a/test/ex/test_examples.py +++ b/test/ex/test_examples.py @@ -43,7 +43,7 @@ def check_import(module): __import__(module) -class ExamplesTest(TestBase): +class ExamplesTest(fixtures.TestBase): # TODO: ensure examples are actually run regardless of check for # "__main__", perhaps standardizing the format of all examples. diff --git a/test/ext/test_associationproxy.py b/test/ext/test_associationproxy.py index 1700282feb..718a5c0981 100644 --- a/test/ext/test_associationproxy.py +++ b/test/ext/test_associationproxy.py @@ -10,7 +10,7 @@ from sqlalchemy.ext.associationproxy import _AssociationList from test.lib import * from test.lib.util import gc_collect from sqlalchemy.sql import not_ -from test.orm import _base +from test.lib import fixtures class DictCollection(dict): @@ -43,7 +43,7 @@ class ObjectCollection(object): return iter(self.values) -class _CollectionOperations(TestBase): +class _CollectionOperations(fixtures.TestBase): def setup(self): collection_class = self.collection_class @@ -667,7 +667,7 @@ class ProxyFactoryTest(ListTest): self._test_sequence_ops() -class ScalarTest(TestBase): +class ScalarTest(fixtures.TestBase): def test_scalar_proxy(self): metadata = MetaData(testing.db) @@ -786,7 +786,7 @@ class ScalarTest(TestBase): p2.bar = 'quux' -class LazyLoadTest(TestBase): +class LazyLoadTest(fixtures.TestBase): def setup(self): metadata = MetaData(testing.db) @@ -908,7 +908,7 @@ class KVChild(object): self.name = name self.value = value -class ReconstitutionTest(TestBase): +class ReconstitutionTest(fixtures.TestBase): def setup(self): metadata = MetaData(testing.db) @@ -1006,7 +1006,7 @@ class PickleKeyFunc(object): def __call__(self, obj): return getattr(obj, self.name) -class ComparatorTest(_base.MappedTest): +class ComparatorTest(fixtures.MappedTest): run_inserts = 'once' run_deletes = None diff --git a/test/ext/test_compiler.py b/test/ext/test_compiler.py index eaa46cc28d..f66fa8c63c 100644 --- a/test/ext/test_compiler.py +++ b/test/ext/test_compiler.py @@ -9,7 +9,7 @@ from sqlalchemy.ext.compiler import compiles from sqlalchemy.sql import table, column, visitors from test.lib import * -class UserDefinedTest(TestBase, AssertsCompiledSQL): +class UserDefinedTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = 'default' def test_column(self): @@ -265,7 +265,7 @@ class UserDefinedTest(TestBase, AssertsCompiledSQL): ) -class DefaultOnExistingTest(TestBase, AssertsCompiledSQL): +class DefaultOnExistingTest(fixtures.TestBase, AssertsCompiledSQL): """Test replacement of default compilation on existing constructs.""" __dialect__ = 'default' diff --git a/test/ext/test_declarative.py b/test/ext/test_declarative.py index 91055911c6..67c94d8cb6 100644 --- a/test/ext/test_declarative.py +++ b/test/ext/test_declarative.py @@ -14,10 +14,10 @@ from sqlalchemy.orm import relationship, create_session, class_mapper, \ Session from test.lib.testing import eq_ from sqlalchemy.util import classproperty -from test.orm._base import ComparableEntity, MappedTest from sqlalchemy.ext.declarative import declared_attr +from test.lib import fixtures -class DeclarativeTestBase(testing.TestBase, testing.AssertsExecutionResults): +class DeclarativeTestBase(fixtures.TestBase, testing.AssertsExecutionResults): def setup(self): global Base Base = decl.declarative_base(testing.db) @@ -29,7 +29,7 @@ class DeclarativeTestBase(testing.TestBase, testing.AssertsExecutionResults): class DeclarativeTest(DeclarativeTestBase): def test_basic(self): - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column('id', Integer, primary_key=True, @@ -37,7 +37,7 @@ class DeclarativeTest(DeclarativeTestBase): name = Column('name', String(50)) addresses = relationship("Address", backref="user") - class Address(Base, ComparableEntity): + class Address(Base, fixtures.ComparableEntity): __tablename__ = 'addresses' id = Column(Integer, primary_key=True, @@ -120,7 +120,7 @@ class DeclarativeTest(DeclarativeTestBase): xyzzy = "magic" # _as_declarative() inspects obj.__class__.__bases__ - class User(BrokenParent,ComparableEntity): + class User(BrokenParent,fixtures.ComparableEntity): __tablename__ = 'users' id = Column('id', Integer, primary_key=True, test_needs_autoincrement=True) @@ -190,7 +190,7 @@ class DeclarativeTest(DeclarativeTestBase): def test_string_dependency_resolution(self): from sqlalchemy.sql import desc - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column(Integer, primary_key=True, @@ -204,7 +204,7 @@ class DeclarativeTest(DeclarativeTestBase): primaryjoin='User.id==Address.user_id', foreign_keys='[Address.user_id]')) - class Address(Base, ComparableEntity): + class Address(Base, fixtures.ComparableEntity): __tablename__ = 'addresses' id = Column(Integer, primary_key=True, @@ -223,7 +223,7 @@ class DeclarativeTest(DeclarativeTestBase): User(name='ed', addresses=[Address(email='xyz'), Address(email='def'), Address(email='abc')])) - class Foo(Base, ComparableEntity): + class Foo(Base, fixtures.ComparableEntity): __tablename__ = 'foo' id = Column(Integer, primary_key=True) @@ -236,13 +236,13 @@ class DeclarativeTest(DeclarativeTestBase): def test_string_dependency_resolution_two(self): - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column(Integer, primary_key=True, test_needs_autoincrement=True) name = Column(String(50)) - class Bar(Base, ComparableEntity): + class Bar(Base, fixtures.ComparableEntity): __tablename__ = 'bar' id = Column(Integer, primary_key=True) rel = relationship('User', @@ -255,7 +255,7 @@ class DeclarativeTest(DeclarativeTestBase): def test_string_dependency_resolution_no_magic(self): """test that full tinkery expressions work as written""" - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column(Integer, primary_key=True) @@ -263,7 +263,7 @@ class DeclarativeTest(DeclarativeTestBase): primaryjoin='User.id==Address.user_id.prop.columns[' '0]') - class Address(Base, ComparableEntity): + class Address(Base, fixtures.ComparableEntity): __tablename__ = 'addresses' id = Column(Integer, primary_key=True) @@ -275,7 +275,7 @@ class DeclarativeTest(DeclarativeTestBase): def test_string_dependency_resolution_in_backref(self): - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column(Integer, primary_key=True) @@ -284,7 +284,7 @@ class DeclarativeTest(DeclarativeTestBase): primaryjoin='User.id==Address.user_id', backref='user') - class Address(Base, ComparableEntity): + class Address(Base, fixtures.ComparableEntity): __tablename__ = 'addresses' id = Column(Integer, primary_key=True) @@ -297,7 +297,7 @@ class DeclarativeTest(DeclarativeTestBase): def test_string_dependency_resolution_tables(self): - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column(Integer, primary_key=True) @@ -308,7 +308,7 @@ class DeclarativeTest(DeclarativeTestBase): secondaryjoin='user_to_prop.c.prop_id=' '=Prop.id', backref='users') - class Prop(Base, ComparableEntity): + class Prop(Base, fixtures.ComparableEntity): __tablename__ = 'props' id = Column(Integer, primary_key=True) @@ -356,7 +356,7 @@ class DeclarativeTest(DeclarativeTestBase): def test_uncompiled_attributes_in_relationship(self): - class Address(Base, ComparableEntity): + class Address(Base, fixtures.ComparableEntity): __tablename__ = 'addresses' id = Column(Integer, primary_key=True, @@ -364,7 +364,7 @@ class DeclarativeTest(DeclarativeTestBase): email = Column(String(50)) user_id = Column(Integer, ForeignKey('users.id')) - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column(Integer, primary_key=True, @@ -502,7 +502,7 @@ class DeclarativeTest(DeclarativeTestBase): def test_add_prop(self): - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column('id', Integer, primary_key=True, @@ -511,7 +511,7 @@ class DeclarativeTest(DeclarativeTestBase): User.name = Column('name', String(50)) User.addresses = relationship('Address', backref='user') - class Address(Base, ComparableEntity): + class Address(Base, fixtures.ComparableEntity): __tablename__ = 'addresses' id = Column(Integer, primary_key=True, @@ -538,7 +538,7 @@ class DeclarativeTest(DeclarativeTestBase): def test_eager_order_by(self): - class Address(Base, ComparableEntity): + class Address(Base, fixtures.ComparableEntity): __tablename__ = 'addresses' id = Column('id', Integer, primary_key=True, @@ -546,7 +546,7 @@ class DeclarativeTest(DeclarativeTestBase): email = Column('email', String(50)) user_id = Column('user_id', Integer, ForeignKey('users.id')) - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column('id', Integer, primary_key=True, @@ -567,7 +567,7 @@ class DeclarativeTest(DeclarativeTestBase): def test_order_by_multi(self): - class Address(Base, ComparableEntity): + class Address(Base, fixtures.ComparableEntity): __tablename__ = 'addresses' id = Column('id', Integer, primary_key=True, @@ -575,7 +575,7 @@ class DeclarativeTest(DeclarativeTestBase): email = Column('email', String(50)) user_id = Column('user_id', Integer, ForeignKey('users.id')) - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column('id', Integer, primary_key=True, @@ -596,7 +596,7 @@ class DeclarativeTest(DeclarativeTestBase): def test_as_declarative(self): - class User(ComparableEntity): + class User(fixtures.ComparableEntity): __tablename__ = 'users' id = Column('id', Integer, primary_key=True, @@ -604,7 +604,7 @@ class DeclarativeTest(DeclarativeTestBase): name = Column('name', String(50)) addresses = relationship('Address', backref='user') - class Address(ComparableEntity): + class Address(fixtures.ComparableEntity): __tablename__ = 'addresses' id = Column('id', Integer, primary_key=True, @@ -662,7 +662,7 @@ class DeclarativeTest(DeclarativeTestBase): def define(): - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column('id', Integer, primary_key=True), @@ -735,7 +735,7 @@ class DeclarativeTest(DeclarativeTestBase): def test_expression(self): - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column('id', Integer, primary_key=True, @@ -743,7 +743,7 @@ class DeclarativeTest(DeclarativeTestBase): name = Column('name', String(50)) addresses = relationship('Address', backref='user') - class Address(Base, ComparableEntity): + class Address(Base, fixtures.ComparableEntity): __tablename__ = 'addresses' id = Column('id', Integer, primary_key=True, @@ -766,7 +766,7 @@ class DeclarativeTest(DeclarativeTestBase): addresses=[Address(email='one'), Address(email='two')])]) def test_useless_declared_attr(self): - class Address(Base, ComparableEntity): + class Address(Base, fixtures.ComparableEntity): __tablename__ = 'addresses' id = Column('id', Integer, primary_key=True, @@ -774,7 +774,7 @@ class DeclarativeTest(DeclarativeTestBase): email = Column('email', String(50)) user_id = Column('user_id', Integer, ForeignKey('users.id')) - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column('id', Integer, primary_key=True, @@ -801,7 +801,7 @@ class DeclarativeTest(DeclarativeTestBase): def test_column(self): - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column('id', Integer, primary_key=True, @@ -822,7 +822,7 @@ class DeclarativeTest(DeclarativeTestBase): def test_column_properties(self): - class Address(Base, ComparableEntity): + class Address(Base, fixtures.ComparableEntity): __tablename__ = 'addresses' id = Column(Integer, primary_key=True, @@ -830,7 +830,7 @@ class DeclarativeTest(DeclarativeTestBase): email = Column(String(50)) user_id = Column(Integer, ForeignKey('users.id')) - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column('id', Integer, primary_key=True, @@ -853,14 +853,14 @@ class DeclarativeTest(DeclarativeTestBase): def test_column_properties_2(self): - class Address(Base, ComparableEntity): + class Address(Base, fixtures.ComparableEntity): __tablename__ = 'addresses' id = Column(Integer, primary_key=True) email = Column(String(50)) user_id = Column(Integer, ForeignKey('users.id')) - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column('id', Integer, primary_key=True) @@ -877,7 +877,7 @@ class DeclarativeTest(DeclarativeTestBase): def test_deferred(self): - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column(Integer, primary_key=True, @@ -898,14 +898,14 @@ class DeclarativeTest(DeclarativeTestBase): self.assert_sql_count(testing.db, go, 1) def test_composite_inline(self): - class AddressComposite(ComparableEntity): + class AddressComposite(fixtures.ComparableEntity): def __init__(self, street, state): self.street = street self.state = state def __composite_values__(self): return [self.street, self.state] - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'user' id = Column(Integer, primary_key=True, test_needs_autoincrement=True) @@ -928,14 +928,14 @@ class DeclarativeTest(DeclarativeTestBase): ) def test_composite_separate(self): - class AddressComposite(ComparableEntity): + class AddressComposite(fixtures.ComparableEntity): def __init__(self, street, state): self.street = street self.state = state def __composite_values__(self): return [self.street, self.state] - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'user' id = Column(Integer, primary_key=True, test_needs_autoincrement=True) @@ -982,7 +982,7 @@ class DeclarativeTest(DeclarativeTestBase): def test_synonym_inline(self): - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column('id', Integer, primary_key=True, @@ -1018,7 +1018,7 @@ class DeclarativeTest(DeclarativeTestBase): def __eq__(self, other): return self.__clause_element__() == other + ' FOO' - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column('id', Integer, primary_key=True, @@ -1036,7 +1036,7 @@ class DeclarativeTest(DeclarativeTestBase): def test_synonym_added(self): - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column('id', Integer, primary_key=True, @@ -1063,7 +1063,7 @@ class DeclarativeTest(DeclarativeTestBase): def test_reentrant_compile_via_foreignkey(self): - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column('id', Integer, primary_key=True, @@ -1071,7 +1071,7 @@ class DeclarativeTest(DeclarativeTestBase): name = Column('name', String(50)) addresses = relationship('Address', backref='user') - class Address(Base, ComparableEntity): + class Address(Base, fixtures.ComparableEntity): __tablename__ = 'addresses' id = Column('id', Integer, primary_key=True, @@ -1098,7 +1098,7 @@ class DeclarativeTest(DeclarativeTestBase): def test_relationship_reference(self): - class Address(Base, ComparableEntity): + class Address(Base, fixtures.ComparableEntity): __tablename__ = 'addresses' id = Column('id', Integer, primary_key=True, @@ -1106,7 +1106,7 @@ class DeclarativeTest(DeclarativeTestBase): email = Column('email', String(50)) user_id = Column('user_id', Integer, ForeignKey('users.id')) - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column('id', Integer, primary_key=True, @@ -1170,7 +1170,7 @@ class DeclarativeTest(DeclarativeTestBase): def test_synonym_for(self): - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column('id', Integer, primary_key=True, @@ -1210,7 +1210,7 @@ class DeclarativeTest(DeclarativeTestBase): ): return op(self.upperself, other, **kw) - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column('id', Integer, primary_key=True, @@ -1314,7 +1314,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): def test_joined(self): - class Company(Base, ComparableEntity): + class Company(Base, fixtures.ComparableEntity): __tablename__ = 'companies' id = Column('id', Integer, primary_key=True, @@ -1322,7 +1322,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): name = Column('name', String(50)) employees = relationship('Person') - class Person(Base, ComparableEntity): + class Person(Base, fixtures.ComparableEntity): __tablename__ = 'people' id = Column('id', Integer, primary_key=True, @@ -1394,7 +1394,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): def test_add_subcol_after_the_fact(self): - class Person(Base, ComparableEntity): + class Person(Base, fixtures.ComparableEntity): __tablename__ = 'people' id = Column('id', Integer, primary_key=True, @@ -1423,7 +1423,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): def test_add_parentcol_after_the_fact(self): - class Person(Base, ComparableEntity): + class Person(Base, fixtures.ComparableEntity): __tablename__ = 'people' id = Column('id', Integer, primary_key=True, @@ -1451,7 +1451,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): def test_add_sub_parentcol_after_the_fact(self): - class Person(Base, ComparableEntity): + class Person(Base, fixtures.ComparableEntity): __tablename__ = 'people' id = Column('id', Integer, primary_key=True, @@ -1488,7 +1488,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): def test_subclass_mixin(self): - class Person(Base, ComparableEntity): + class Person(Base, fixtures.ComparableEntity): __tablename__ = 'people' id = Column('id', Integer, primary_key=True) @@ -1615,7 +1615,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): """test single inheritance where all the columns are on the base class.""" - class Company(Base, ComparableEntity): + class Company(Base, fixtures.ComparableEntity): __tablename__ = 'companies' id = Column('id', Integer, primary_key=True, @@ -1623,7 +1623,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): name = Column('name', String(50)) employees = relationship('Person') - class Person(Base, ComparableEntity): + class Person(Base, fixtures.ComparableEntity): __tablename__ = 'people' id = Column('id', Integer, primary_key=True, @@ -1672,7 +1672,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): """ - class Company(Base, ComparableEntity): + class Company(Base, fixtures.ComparableEntity): __tablename__ = 'companies' id = Column('id', Integer, primary_key=True, @@ -1680,7 +1680,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): name = Column('name', String(50)) employees = relationship('Person') - class Person(Base, ComparableEntity): + class Person(Base, fixtures.ComparableEntity): __tablename__ = 'people' id = Column(Integer, primary_key=True, @@ -1738,7 +1738,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): def test_joined_from_single(self): - class Company(Base, ComparableEntity): + class Company(Base, fixtures.ComparableEntity): __tablename__ = 'companies' id = Column('id', Integer, primary_key=True, @@ -1746,7 +1746,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): name = Column('name', String(50)) employees = relationship('Person') - class Person(Base, ComparableEntity): + class Person(Base, fixtures.ComparableEntity): __tablename__ = 'people' id = Column(Integer, primary_key=True, @@ -1801,7 +1801,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): def test_add_deferred(self): - class Person(Base, ComparableEntity): + class Person(Base, fixtures.ComparableEntity): __tablename__ = 'people' id = Column('id', Integer, primary_key=True, @@ -1826,7 +1826,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): """ - class Person(Base, ComparableEntity): + class Person(Base, fixtures.ComparableEntity): __tablename__ = 'people' id = Column(Integer, primary_key=True, @@ -1842,7 +1842,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): ForeignKey('languages.id')) primary_language = relationship('Language') - class Language(Base, ComparableEntity): + class Language(Base, fixtures.ComparableEntity): __tablename__ = 'languages' id = Column(Integer, primary_key=True, @@ -1878,7 +1878,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): def test_single_three_levels(self): - class Person(Base, ComparableEntity): + class Person(Base, fixtures.ComparableEntity): __tablename__ = 'people' id = Column(Integer, primary_key=True) @@ -1952,7 +1952,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): def test_single_no_special_cols(self): - class Person(Base, ComparableEntity): + class Person(Base, fixtures.ComparableEntity): __tablename__ = 'people' id = Column('id', Integer, primary_key=True) @@ -1974,7 +1974,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): def test_single_no_table_args(self): - class Person(Base, ComparableEntity): + class Person(Base, fixtures.ComparableEntity): __tablename__ = 'people' id = Column('id', Integer, primary_key=True) @@ -2012,7 +2012,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): punion = polymorphic_union({'engineer': engineers, 'manager' : managers}, 'type', 'punion') - class Person(Base, ComparableEntity): + class Person(Base, fixtures.ComparableEntity): __table__ = punion __mapper_args__ = {'polymorphic_on': punion.c.type} @@ -2045,7 +2045,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): def test_concrete_inline_non_polymorphic(self): """test the example from the declarative docs.""" - class Person(Base, ComparableEntity): + class Person(Base, fixtures.ComparableEntity): __tablename__ = 'people' id = Column(Integer, primary_key=True, @@ -2086,21 +2086,21 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): def _produce_test(inline, stringbased): - class ExplicitJoinTest(MappedTest): + class ExplicitJoinTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): global User, Address Base = decl.declarative_base(metadata=metadata) - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' id = Column(Integer, primary_key=True, test_needs_autoincrement=True) name = Column(String(50)) - class Address(Base, ComparableEntity): + class Address(Base, fixtures.ComparableEntity): __tablename__ = 'addresses' id = Column(Integer, primary_key=True, @@ -2166,7 +2166,7 @@ for inline in True, False: exec '%s = testclass' % testclass.__name__ del testclass -class DeclarativeReflectionTest(testing.TestBase): +class DeclarativeReflectionTest(fixtures.TestBase): @classmethod def setup_class(cls): @@ -2211,7 +2211,7 @@ class DeclarativeReflectionTest(testing.TestBase): def test_basic(self): meta = MetaData(testing.db) - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' __autoload__ = True @@ -2220,7 +2220,7 @@ class DeclarativeReflectionTest(testing.TestBase): test_needs_autoincrement=True) addresses = relationship('Address', backref='user') - class Address(Base, ComparableEntity): + class Address(Base, fixtures.ComparableEntity): __tablename__ = 'addresses' __autoload__ = True @@ -2243,7 +2243,7 @@ class DeclarativeReflectionTest(testing.TestBase): def test_rekey(self): meta = MetaData(testing.db) - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' __autoload__ = True @@ -2253,7 +2253,7 @@ class DeclarativeReflectionTest(testing.TestBase): nom = Column('name', String(50), key='nom') addresses = relationship('Address', backref='user') - class Address(Base, ComparableEntity): + class Address(Base, fixtures.ComparableEntity): __tablename__ = 'addresses' __autoload__ = True @@ -2277,7 +2277,7 @@ class DeclarativeReflectionTest(testing.TestBase): def test_supplied_fk(self): meta = MetaData(testing.db) - class IMHandle(Base, ComparableEntity): + class IMHandle(Base, fixtures.ComparableEntity): __tablename__ = 'imhandles' __autoload__ = True @@ -2286,7 +2286,7 @@ class DeclarativeReflectionTest(testing.TestBase): test_needs_autoincrement=True) user_id = Column('user_id', Integer, ForeignKey('users.id')) - class User(Base, ComparableEntity): + class User(Base, fixtures.ComparableEntity): __tablename__ = 'users' __autoload__ = True diff --git a/test/ext/test_horizontal_shard.py b/test/ext/test_horizontal_shard.py index ff99f22dc2..a570de1ff9 100644 --- a/test/ext/test_horizontal_shard.py +++ b/test/ext/test_horizontal_shard.py @@ -11,7 +11,7 @@ from nose import SkipTest # TODO: ShardTest can be turned into a base for further subclasses -class ShardTest(TestBase): +class ShardTest(fixtures.TestBase): def setUp(self): global db1, db2, db3, db4, weather_locations, weather_reports diff --git a/test/ext/test_hybrid.py b/test/ext/test_hybrid.py index cab1c90bb3..649b796f72 100644 --- a/test/ext/test_hybrid.py +++ b/test/ext/test_hybrid.py @@ -3,9 +3,10 @@ from sqlalchemy.orm import relationship, Session, aliased from test.lib.schema import Column from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.ext import hybrid -from test.lib.testing import TestBase, eq_, AssertsCompiledSQL +from test.lib.testing import eq_, AssertsCompiledSQL +from test.lib import fixtures -class PropertyComparatorTest(TestBase, AssertsCompiledSQL): +class PropertyComparatorTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = 'default' def _fixture(self): @@ -77,7 +78,7 @@ class PropertyComparatorTest(TestBase, AssertsCompiledSQL): "FROM a AS a_1 WHERE upper(a_1.value) = upper(:upper_1)" ) -class PropertyExpressionTest(TestBase, AssertsCompiledSQL): +class PropertyExpressionTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = 'default' def _fixture(self): Base = declarative_base() @@ -143,7 +144,7 @@ class PropertyExpressionTest(TestBase, AssertsCompiledSQL): "FROM a AS a_1 WHERE foo(a_1.value) + bar(a_1.value) = :param_1" ) -class PropertyValueTest(TestBase, AssertsCompiledSQL): +class PropertyValueTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = 'default' def _fixture(self): Base = declarative_base() @@ -169,7 +170,7 @@ class PropertyValueTest(TestBase, AssertsCompiledSQL): eq_(a1.value, 5) eq_(a1._value, 10) -class MethodExpressionTest(TestBase, AssertsCompiledSQL): +class MethodExpressionTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = 'default' def _fixture(self): Base = declarative_base() diff --git a/test/ext/test_mutable.py b/test/ext/test_mutable.py index c3d5aecd8c..236d711b2a 100644 --- a/test/ext/test_mutable.py +++ b/test/ext/test_mutable.py @@ -7,11 +7,11 @@ from test.lib.schema import Table, Column from test.lib.testing import eq_ from test.lib.util import picklers from test.lib import testing -from test.orm import _base +from test.lib import fixtures import sys import pickle -class Foo(_base.BasicEntity): +class Foo(fixtures.BasicEntity): pass class _MutableDictTestBase(object): @@ -100,7 +100,7 @@ class _MutableDictTestBase(object): eq_(f1.non_mutable_data, {'a':'b'}) -class MutableWithScalarPickleTest(_MutableDictTestBase, _base.MappedTest): +class MutableWithScalarPickleTest(_MutableDictTestBase, fixtures.MappedTest): @classmethod def define_tables(cls, metadata): MutationDict = cls._type_fixture() @@ -114,7 +114,7 @@ class MutableWithScalarPickleTest(_MutableDictTestBase, _base.MappedTest): def test_non_mutable(self): self._test_non_mutable() -class MutableWithScalarJSONTest(_MutableDictTestBase, _base.MappedTest): +class MutableWithScalarJSONTest(_MutableDictTestBase, fixtures.MappedTest): # json introduced in 2.6 __skip_if__ = lambda : sys.version_info < (2, 6), @@ -147,7 +147,7 @@ class MutableWithScalarJSONTest(_MutableDictTestBase, _base.MappedTest): def test_non_mutable(self): self._test_non_mutable() -class MutableAssociationScalarPickleTest(_MutableDictTestBase, _base.MappedTest): +class MutableAssociationScalarPickleTest(_MutableDictTestBase, fixtures.MappedTest): @classmethod def define_tables(cls, metadata): MutationDict = cls._type_fixture() @@ -158,7 +158,7 @@ class MutableAssociationScalarPickleTest(_MutableDictTestBase, _base.MappedTest) Column('data', PickleType) ) -class MutableAssociationScalarJSONTest(_MutableDictTestBase, _base.MappedTest): +class MutableAssociationScalarJSONTest(_MutableDictTestBase, fixtures.MappedTest): # json introduced in 2.6 __skip_if__ = lambda : sys.version_info < (2, 6), @@ -204,7 +204,7 @@ class _CompositeTestBase(object): ClassManager.dispatch._clear() super(_CompositeTestBase, self).teardown() -class MutableCompositesTest(_CompositeTestBase, _base.MappedTest): +class MutableCompositesTest(_CompositeTestBase, fixtures.MappedTest): @classmethod def _type_fixture(cls): diff --git a/test/ext/test_orderinglist.py b/test/ext/test_orderinglist.py index f7f8f7fa76..dfeac5c3ed 100644 --- a/test/ext/test_orderinglist.py +++ b/test/ext/test_orderinglist.py @@ -37,7 +37,7 @@ def alpha_ordering(index, collection): s += chr(index + 65) return s -class OrderingListTest(TestBase): +class OrderingListTest(fixtures.TestBase): def setup(self): global metadata, slides_table, bullets_table, Slide, Bullet slides_table, bullets_table = None, None diff --git a/test/ext/test_serializer.py b/test/ext/test_serializer.py index 862a871afc..b7b8bd8892 100644 --- a/test/ext/test_serializer.py +++ b/test/ext/test_serializer.py @@ -10,17 +10,17 @@ from test.lib.schema import Column from sqlalchemy.orm import relationship, sessionmaker, scoped_session, \ class_mapper, mapper, joinedload, configure_mappers, aliased from test.lib.testing import eq_ -from test.orm._base import ComparableEntity, MappedTest +from test.lib import fixtures -class User(ComparableEntity): +class User(fixtures.ComparableEntity): pass -class Address(ComparableEntity): +class Address(fixtures.ComparableEntity): pass -class SerializeTest(MappedTest): +class SerializeTest(fixtures.MappedTest): run_setup_mappers = 'once' run_inserts = 'once' diff --git a/test/ext/test_sqlsoup.py b/test/ext/test_sqlsoup.py index dfee5748ff..88601b5cfb 100644 --- a/test/ext/test_sqlsoup.py +++ b/test/ext/test_sqlsoup.py @@ -1,13 +1,13 @@ from sqlalchemy.ext import sqlsoup -from test.lib.testing import TestBase, eq_, assert_raises, \ +from test.lib.testing import eq_, assert_raises, \ assert_raises_message from sqlalchemy import create_engine, or_, desc, select, func, exc, \ Table, util, Column, Integer from sqlalchemy.orm import scoped_session, sessionmaker import datetime +from test.lib import fixtures - -class SQLSoupTest(TestBase): +class SQLSoupTest(fixtures.TestBase): __requires__ = 'sqlite', diff --git a/test/lib/__init__.py b/test/lib/__init__.py index 452848aff1..68876c4479 100644 --- a/test/lib/__init__.py +++ b/test/lib/__init__.py @@ -7,20 +7,17 @@ by noseplugin.NoseSQLAlchemy. """ from test.bootstrap import config -from test.lib import testing, engines, requires, profiling, pickleable +from test.lib import testing, engines, requires, profiling, pickleable, \ + fixtures from test.lib.schema import Column, Table -from test.lib.testing import \ - AssertsCompiledSQL, \ - AssertsExecutionResults, \ - ComparesTables, \ - TestBase, \ - rowset +from test.lib.testing import AssertsCompiledSQL, \ + AssertsExecutionResults, ComparesTables, rowset __all__ = ('testing', 'Column', 'Table', - 'rowset', - 'TestBase', 'AssertsExecutionResults', + 'rowset','fixtures', + 'AssertsExecutionResults', 'AssertsCompiledSQL', 'ComparesTables', 'engines', 'profiling', 'pickleable') diff --git a/test/engine/_base.py b/test/lib/fixtures.py similarity index 51% rename from test/engine/_base.py rename to test/lib/fixtures.py index 23892ffd63..7eab2d9c1c 100644 --- a/test/engine/_base.py +++ b/test/lib/fixtures.py @@ -1,13 +1,37 @@ -import sqlalchemy as sa from test.lib import testing from test.lib.testing import adict from test.lib.engines import drop_all_tables import sys +import sqlalchemy as sa +from test.lib.entities import BasicEntity, ComparableEntity -class TablesTest(testing.TestBase): - """An integration test that creates and uses tables.""" +class TestBase(object): + # A sequence of database names to always run, regardless of the + # constraints below. + __whitelist__ = () - # 'once', 'each', None + # A sequence of requirement names matching testing.requires decorators + __requires__ = () + + # A sequence of dialect names to exclude from the test class. + __unsupported_on__ = () + + # If present, test class is only runnable for the *single* specified + # dialect. If you need multiple, use __unsupported_on__ and invert. + __only_on__ = None + + # A sequence of no-arg callables. If any are True, the entire testcase is + # skipped. + __skip_if__ = None + + _artifact_registries = () + + def assert_(self, val, msg=None): + assert val, msg + +class TablesTest(TestBase): + + # 'once', None run_setup_bind = 'once' # 'once', 'each', None @@ -22,7 +46,7 @@ class TablesTest(testing.TestBase): # 'each', None run_deletes = 'each' - # 'once', 'each', None + # 'once', None run_dispose_bind = None bind = None @@ -100,22 +124,12 @@ class TablesTest(testing.TestBase): print >> sys.stderr, "Error emptying table %s: %r" % ( table, ex) - def _setup_each_bind(self): - if self.setup_bind == 'each': - setattr(cls, 'bind', self.setup_bind()) - - def _teardown_each_bind(self): - if self.run_dispose_bind == 'each': - self.dispose_bind(self.bind) - def setup(self): - self._setup_each_bind() self._setup_each_tables() self._setup_each_inserts() def teardown(self): self._teardown_each_tables() - self._teardown_each_bind() @classmethod def _teardown_once_metadata_bind(cls): @@ -180,3 +194,129 @@ class TablesTest(testing.TestBase): for column_values in rows[table]]) +class _ORMTest(object): + __requires__ = ('subqueries',) + + @classmethod + def teardown_class(cls): + sa.orm.session.Session.close_all() + sa.orm.clear_mappers() + +class ORMTest(_ORMTest, TestBase): + pass + +class MappedTest(_ORMTest, TablesTest, testing.AssertsExecutionResults): + # 'once', 'each', None + run_setup_classes = 'once' + + # 'once', 'each', None + run_setup_mappers = 'each' + + classes = None + + @classmethod + def setup_class(cls): + cls._init_class() + + if cls.classes is None: + cls.classes = adict() + + cls._setup_once_tables() + cls._setup_once_classes() + cls._setup_once_mappers() + cls._setup_once_inserts() + + @classmethod + def teardown_class(cls): + cls.classes.clear() + _ORMTest.teardown_class() + cls._teardown_once_metadata_bind() + + def setup(self): + self._setup_each_tables() + self._setup_each_mappers() + self._setup_each_inserts() + + def teardown(self): + sa.orm.session.Session.close_all() + self._teardown_each_mappers() + self._teardown_each_tables() + + @classmethod + def _setup_once_classes(cls): + if cls.run_setup_classes == 'once': + cls._with_register_classes(cls.setup_classes) + + @classmethod + def _setup_once_mappers(cls): + if cls.run_setup_mappers == 'once': + cls._with_register_classes(cls.setup_mappers) + + def _setup_each_mappers(self): + if self.run_setup_mappers == 'each': + self._with_register_classes(self.setup_mappers) + + @classmethod + def _with_register_classes(cls, fn): + """Run a setup method, framing the operation with a Base class + that will catch new subclasses to be established within + the "classes" registry. + + """ + class Base(object): + pass + class Basic(BasicEntity, Base): + pass + class Comparable(ComparableEntity, Base): + pass + cls.Basic = Basic + cls.Comparable = Comparable + fn() + for class_ in subclasses(Base): + cls.classes[class_.__name__] = class_ + + def _teardown_each_mappers(self): + # some tests create mappers in the test bodies + # and will define setup_mappers as None - + # clear mappers in any case + if self.run_setup_mappers != 'once': + sa.orm.clear_mappers() + if self.run_setup_classes == 'each': + cls.classes.clear() + + @classmethod + def setup_classes(cls): + pass + + @classmethod + def setup_mappers(cls): + pass + + @classmethod + def _load_fixtures(cls): + """Insert rows as represented by the fixtures() method.""" + + headers, rows = {}, {} + for table, data in cls.fixtures().iteritems(): + if isinstance(table, basestring): + table = cls.tables[table] + headers[table] = data[0] + rows[table] = data[1:] + for table in cls.metadata.sorted_tables: + if table not in headers: + continue + table.bind.execute( + table.insert(), + [dict(zip(headers[table], column_values)) + for column_values in rows[table]]) + + +def subclasses(cls): + subs, process = set(), set(cls.__subclasses__()) + while process: + cls = process.pop() + if cls not in subs: + subs.add(cls) + process |= set(cls.__subclasses__()) + return subs + diff --git a/test/lib/pickleable.py b/test/lib/pickleable.py index 58422a9146..550e0e5020 100644 --- a/test/lib/pickleable.py +++ b/test/lib/pickleable.py @@ -1,27 +1,27 @@ """Classes used in pickling tests, need to be at the module level for unpickling.""" -from test.orm import _base +from test.lib import fixtures -class User(_base.ComparableEntity): +class User(fixtures.ComparableEntity): pass -class Order(_base.ComparableEntity): +class Order(fixtures.ComparableEntity): pass class EmailUser(User): pass -class Address(_base.ComparableEntity): +class Address(fixtures.ComparableEntity): pass # TODO: these are kind of arbitrary.... -class Child1(_base.ComparableEntity): +class Child1(fixtures.ComparableEntity): pass -class Child2(_base.ComparableEntity): +class Child2(fixtures.ComparableEntity): pass -class Parent(_base.ComparableEntity): +class Parent(fixtures.ComparableEntity): pass class Screen(object): diff --git a/test/lib/testing.py b/test/lib/testing.py index e815a2dff0..95cda95e84 100644 --- a/test/lib/testing.py +++ b/test/lib/testing.py @@ -563,30 +563,6 @@ class adict(dict): return tuple([self[key] for key in keys]) -class TestBase(object): - # A sequence of database names to always run, regardless of the - # constraints below. - __whitelist__ = () - - # A sequence of requirement names matching testing.requires decorators - __requires__ = () - - # A sequence of dialect names to exclude from the test class. - __unsupported_on__ = () - - # If present, test class is only runnable for the *single* specified - # dialect. If you need multiple, use __unsupported_on__ and invert. - __only_on__ = None - - # A sequence of no-arg callables. If any are True, the entire testcase is - # skipped. - __skip_if__ = None - - _artifact_registries = () - - def assert_(self, val, msg=None): - assert val, msg - class AssertsCompiledSQL(object): def assert_compile(self, clause, result, params=None, checkparams=None, dialect=None, diff --git a/test/orm/_base.py b/test/orm/_base.py deleted file mode 100644 index 764ac30c07..0000000000 --- a/test/orm/_base.py +++ /dev/null @@ -1,137 +0,0 @@ -import inspect -import sys -import types -import sqlalchemy as sa -from sqlalchemy import exc as sa_exc -from test.lib import config, testing -from test.lib.testing import adict -from test.lib.entities import BasicEntity, ComparableEntity -from test.engine._base import TablesTest - -class _ORMTest(object): - __requires__ = ('subqueries',) - - @classmethod - def teardown_class(cls): - sa.orm.session.Session.close_all() - sa.orm.clear_mappers() - -class ORMTest(_ORMTest, testing.TestBase): - pass - -class MappedTest(_ORMTest, TablesTest, testing.AssertsExecutionResults): - # 'once', 'each', None - run_setup_classes = 'once' - - # 'once', 'each', None - run_setup_mappers = 'each' - - classes = None - - @classmethod - def setup_class(cls): - cls._init_class() - - if cls.classes is None: - cls.classes = adict() - - cls._setup_once_tables() - cls._setup_once_classes() - cls._setup_once_mappers() - cls._setup_once_inserts() - - @classmethod - def teardown_class(cls): - cls.classes.clear() - _ORMTest.teardown_class() - cls._teardown_once_metadata_bind() - - def setup(self): - self._setup_each_tables() - self._setup_each_mappers() - self._setup_each_inserts() - - def teardown(self): - sa.orm.session.Session.close_all() - self._teardown_each_mappers() - self._teardown_each_tables() - self._teardown_each_bind() - - @classmethod - def _setup_once_classes(cls): - if cls.run_setup_classes == 'once': - cls._with_register_classes(cls.setup_classes) - - @classmethod - def _setup_once_mappers(cls): - if cls.run_setup_mappers == 'once': - cls._with_register_classes(cls.setup_mappers) - - def _setup_each_mappers(self): - if self.run_setup_mappers == 'each': - self._with_register_classes(self.setup_mappers) - - @classmethod - def _with_register_classes(cls, fn): - """Run a setup method, framing the operation with a Base class - that will catch new subclasses to be established within - the "classes" registry. - - """ - class Base(object): - pass - class Basic(BasicEntity, Base): - pass - class Comparable(ComparableEntity, Base): - pass - cls.Basic = Basic - cls.Comparable = Comparable - fn() - for class_ in subclasses(Base): - cls.classes[class_.__name__] = class_ - - def _teardown_each_mappers(self): - # some tests create mappers in the test bodies - # and will define setup_mappers as None - - # clear mappers in any case - if self.run_setup_mappers != 'once': - sa.orm.clear_mappers() - if self.run_setup_classes == 'each': - cls.classes.clear() - - @classmethod - def setup_classes(cls): - pass - - @classmethod - def setup_mappers(cls): - pass - - @classmethod - def _load_fixtures(cls): - """Insert rows as represented by the fixtures() method.""" - - headers, rows = {}, {} - for table, data in cls.fixtures().iteritems(): - if isinstance(table, basestring): - table = cls.tables[table] - headers[table] = data[0] - rows[table] = data[1:] - for table in cls.metadata.sorted_tables: - if table not in headers: - continue - table.bind.execute( - table.insert(), - [dict(zip(headers[table], column_values)) - for column_values in rows[table]]) - - -def subclasses(cls): - subs, process = set(), set(cls.__subclasses__()) - while process: - cls = process.pop() - if cls not in subs: - subs.add(cls) - process |= set(cls.__subclasses__()) - return subs - diff --git a/test/orm/_fixtures.py b/test/orm/_fixtures.py index 412f93afe3..5def54e3a4 100644 --- a/test/orm/_fixtures.py +++ b/test/orm/_fixtures.py @@ -3,12 +3,12 @@ from sqlalchemy import util from test.lib.schema import Table from test.lib.schema import Column from sqlalchemy.orm import attributes -from test.orm import _base +from test.lib import fixtures __all__ = () -class FixtureTest(_base.MappedTest): +class FixtureTest(fixtures.MappedTest): """A MappedTest pre-configured with a common set of fixtures. """ diff --git a/test/orm/inheritance/test_abc_inheritance.py b/test/orm/inheritance/test_abc_inheritance.py index d370ec9cbd..6a2f579ae6 100644 --- a/test/orm/inheritance/test_abc_inheritance.py +++ b/test/orm/inheritance/test_abc_inheritance.py @@ -4,7 +4,7 @@ from sqlalchemy.orm.interfaces import ONETOMANY, MANYTOONE from test.lib import testing from test.lib.schema import Table, Column -from test.orm import _base +from test.lib import fixtures def produce_test(parent, child, direction): @@ -15,7 +15,7 @@ def produce_test(parent, child, direction): the old "no discriminator column" pattern is used. """ - class ABCTest(_base.MappedTest): + class ABCTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): global ta, tb, tc diff --git a/test/orm/inheritance/test_abc_polymorphic.py b/test/orm/inheritance/test_abc_polymorphic.py index f18adac7a6..8d1b5fec08 100644 --- a/test/orm/inheritance/test_abc_polymorphic.py +++ b/test/orm/inheritance/test_abc_polymorphic.py @@ -3,10 +3,11 @@ from sqlalchemy import util from sqlalchemy.orm import * from test.lib.util import function_named -from test.orm import _base, _fixtures +from test.lib import fixtures +from test.orm import _fixtures from test.lib.schema import Table, Column -class ABCTest(_base.MappedTest): +class ABCTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): global a, b, c @@ -24,7 +25,7 @@ class ABCTest(_base.MappedTest): def make_test(fetchtype): def test_roundtrip(self): - class A(_base.ComparableEntity):pass + class A(fixtures.ComparableEntity):pass class B(A):pass class C(B):pass diff --git a/test/orm/inheritance/test_basic.py b/test/orm/inheritance/test_basic.py index de677048e3..cdd9bf56b4 100644 --- a/test/orm/inheritance/test_basic.py +++ b/test/orm/inheritance/test_basic.py @@ -7,10 +7,11 @@ from sqlalchemy.orm import exc as orm_exc, attributes from test.lib.assertsql import AllOf, CompiledSQL from test.lib import testing, engines -from test.orm import _base, _fixtures +from test.lib import fixtures +from test.orm import _fixtures from test.lib.schema import Table, Column -class O2MTest(_base.MappedTest): +class O2MTest(fixtures.MappedTest): """deals with inheritance and one-to-many relationships""" @classmethod def define_tables(cls, metadata): @@ -73,7 +74,7 @@ class O2MTest(_base.MappedTest): self.assert_(l[0].parent_foo.data == 'foo #1' and l[1].parent_foo.data == 'foo #1') -class PolymorphicOnNotLocalTest(_base.MappedTest): +class PolymorphicOnNotLocalTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): t1 = Table('t1', metadata, @@ -129,7 +130,7 @@ class PolymorphicOnNotLocalTest(_base.MappedTest): ) -class FalseDiscriminatorTest(_base.MappedTest): +class FalseDiscriminatorTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): global t1 @@ -163,7 +164,7 @@ class FalseDiscriminatorTest(_base.MappedTest): sess.expunge_all() assert sess.query(Ding).one() is not None -class PolymorphicSynonymTest(_base.MappedTest): +class PolymorphicSynonymTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): global t1, t2 @@ -178,7 +179,7 @@ class PolymorphicSynonymTest(_base.MappedTest): Column('data', String(10), nullable=False)) def test_polymorphic_synonym(self): - class T1(_base.ComparableEntity): + class T1(fixtures.ComparableEntity): def info(self): return "THE INFO IS:" + self._info def _set_info(self, x): @@ -202,7 +203,7 @@ class PolymorphicSynonymTest(_base.MappedTest): eq_(sess.query(T2).filter(T2.info=='at2').one(), at2) eq_(at2.info, "THE INFO IS:at2") -class PolymorphicAttributeManagementTest(_base.MappedTest): +class PolymorphicAttributeManagementTest(fixtures.MappedTest): """Test polymorphic_on can be assigned, can be mirrored, etc.""" run_setup_mappers = 'once' @@ -230,7 +231,7 @@ class PolymorphicAttributeManagementTest(_base.MappedTest): cls.tables.table_c, cls.tables.table_a) - class A(cls.Comparable): + class A(cls.Basic): pass class B(A): pass @@ -285,7 +286,7 @@ class PolymorphicAttributeManagementTest(_base.MappedTest): sess.close() assert isinstance(sess.query(B).first(), C) -class CascadeTest(_base.MappedTest): +class CascadeTest(fixtures.MappedTest): """that cascades on polymorphic relationships continue cascading along the path of the instance's mapper, not the base mapper.""" @@ -318,13 +319,13 @@ class CascadeTest(_base.MappedTest): Column('data', String(30))) def test_cascade(self): - class T1(_base.ComparableEntity): + class T1(fixtures.BasicEntity): pass - class T2(_base.ComparableEntity): + class T2(fixtures.BasicEntity): pass class T3(T2): pass - class T4(_base.ComparableEntity): + class T4(fixtures.BasicEntity): pass mapper(T1, t1, properties={ @@ -358,7 +359,7 @@ class CascadeTest(_base.MappedTest): assert t4_1 in sess.deleted sess.flush() -class M2OUseGetTest(_base.MappedTest): +class M2OUseGetTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('base', metadata, @@ -379,7 +380,7 @@ class M2OUseGetTest(_base.MappedTest): self.tables.related) # test [ticket:1186] - class Base(_base.BasicEntity): + class Base(fixtures.BasicEntity): pass class Sub(Base): pass @@ -413,7 +414,7 @@ class M2OUseGetTest(_base.MappedTest): self.assert_sql_count(testing.db, go, 0) -class GetTest(_base.MappedTest): +class GetTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): global foo, bar, blub @@ -515,7 +516,7 @@ class GetTest(_base.MappedTest): self.assert_sql_count(testing.db, go, 3) -class EagerLazyTest(_base.MappedTest): +class EagerLazyTest(fixtures.MappedTest): """tests eager load/lazy load of child items off inheritance mappers, tests that LazyLoader constructs the right query condition.""" @@ -561,7 +562,7 @@ class EagerLazyTest(_base.MappedTest): self.assert_(len(q.first().lazy) == 1) self.assert_(len(q.first().eager) == 1) -class EagerTargetingTest(_base.MappedTest): +class EagerTargetingTest(fixtures.MappedTest): """test a scenario where joined table inheritance might be confused as an eagerly loaded joined table.""" @@ -582,7 +583,7 @@ class EagerTargetingTest(_base.MappedTest): def test_adapt_stringency(self): b_table, a_table = self.tables.b_table, self.tables.a_table - class A(_base.ComparableEntity): + class A(fixtures.ComparableEntity): pass class B(A): pass @@ -618,7 +619,7 @@ class EagerTargetingTest(_base.MappedTest): eq_(node, B(id=1, name='b1',b_data='i')) eq_(node.children[0], B(id=2, name='b2',b_data='l')) -class FlushTest(_base.MappedTest): +class FlushTest(fixtures.MappedTest): """test dependency sorting among inheriting mappers""" @classmethod @@ -718,7 +719,7 @@ class FlushTest(_base.MappedTest): sess.flush() assert user_roles.count().scalar() == 1 -class VersioningTest(_base.MappedTest): +class VersioningTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('base', metadata, @@ -743,7 +744,7 @@ class VersioningTest(_base.MappedTest): self.tables.base, self.tables.stuff) - class Base(_base.ComparableEntity): + class Base(fixtures.BasicEntity): pass class Sub(Base): pass @@ -794,7 +795,7 @@ class VersioningTest(_base.MappedTest): def test_delete(self): subtable, base = self.tables.subtable, self.tables.base - class Base(_base.ComparableEntity): + class Base(fixtures.BasicEntity): pass class Sub(Base): pass @@ -832,7 +833,7 @@ class VersioningTest(_base.MappedTest): else: sess.flush() -class DistinctPKTest(_base.MappedTest): +class DistinctPKTest(fixtures.MappedTest): """test the construction of mapper.primary_key when an inheriting relationship joins on a column other than primary key column.""" @@ -917,7 +918,7 @@ class DistinctPKTest(_base.MappedTest): assert alice1.name == alice2.name == 'alice' assert bob.name == 'bob' -class SyncCompileTest(_base.MappedTest): +class SyncCompileTest(fixtures.MappedTest): """test that syncrules compile properly on custom inherit conds""" @classmethod @@ -986,7 +987,7 @@ class SyncCompileTest(_base.MappedTest): assert len(session.query(B).all()) == 2 assert len(session.query(C).all()) == 1 -class OverrideColKeyTest(_base.MappedTest): +class OverrideColKeyTest(fixtures.MappedTest): """test overriding of column attributes.""" @classmethod @@ -1206,7 +1207,7 @@ class OverrideColKeyTest(_base.MappedTest): assert sess.query(Base).get(b1.base_id).data == "this is base" assert sess.query(Sub).get(s1.base_id).data == "this is base" -class OptimizedLoadTest(_base.MappedTest): +class OptimizedLoadTest(fixtures.MappedTest): """tests for the "optimized load" routine.""" @classmethod @@ -1239,7 +1240,7 @@ class OptimizedLoadTest(_base.MappedTest): """"test that the 'optimized load' routine doesn't crash when a column in the join condition is not available.""" - class Base(_base.BasicEntity): + class Base(fixtures.ComparableEntity): pass class Sub(Base): pass @@ -1267,7 +1268,7 @@ class OptimizedLoadTest(_base.MappedTest): def test_column_expression(self): base, sub = self.tables.base, self.tables.sub - class Base(_base.BasicEntity): + class Base(fixtures.ComparableEntity): pass class Sub(Base): pass @@ -1286,7 +1287,7 @@ class OptimizedLoadTest(_base.MappedTest): def test_column_expression_joined(self): base, sub = self.tables.base, self.tables.sub - class Base(_base.ComparableEntity): + class Base(fixtures.ComparableEntity): pass class Sub(Base): pass @@ -1317,7 +1318,7 @@ class OptimizedLoadTest(_base.MappedTest): def test_composite_column_joined(self): base, with_comp = self.tables.base, self.tables.with_comp - class Base(_base.ComparableEntity): + class Base(fixtures.BasicEntity): pass class WithComp(Base): pass @@ -1348,7 +1349,7 @@ class OptimizedLoadTest(_base.MappedTest): def test_load_expired_on_pending(self): base, sub = self.tables.base, self.tables.sub - class Base(_base.ComparableEntity): + class Base(fixtures.BasicEntity): pass class Sub(Base): pass @@ -1385,7 +1386,7 @@ class OptimizedLoadTest(_base.MappedTest): def test_dont_generate_on_none(self): base, sub = self.tables.base, self.tables.sub - class Base(_base.ComparableEntity): + class Base(fixtures.BasicEntity): pass class Sub(Base): pass @@ -1414,7 +1415,7 @@ class OptimizedLoadTest(_base.MappedTest): self.tables.sub, self.tables.subsub) - class Base(_base.ComparableEntity): + class Base(fixtures.BasicEntity): pass class Sub(Base): pass @@ -1462,7 +1463,7 @@ class OptimizedLoadTest(_base.MappedTest): ), ) -class NoPKOnSubTableWarningTest(testing.TestBase): +class NoPKOnSubTableWarningTest(fixtures.TestBase): def _fixture(self): metadata = MetaData() @@ -1505,7 +1506,7 @@ class NoPKOnSubTableWarningTest(testing.TestBase): mc = mapper(C, child, inherits=P, primary_key=[parent.c.id]) eq_(mc.primary_key, (parent.c.id,)) -class PKDiscriminatorTest(_base.MappedTest): +class PKDiscriminatorTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): parents = Table('parents', metadata, @@ -1559,7 +1560,7 @@ class PKDiscriminatorTest(_base.MappedTest): assert a.name=='a1new' assert p.name=='p1new' -class NoPolyIdentInMiddleTest(_base.MappedTest): +class NoPolyIdentInMiddleTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('base', metadata, @@ -1636,7 +1637,7 @@ class NoPolyIdentInMiddleTest(_base.MappedTest): [C(), D()] ) -class DeleteOrphanTest(_base.MappedTest): +class DeleteOrphanTest(fixtures.MappedTest): """Test the fairly obvious, that an error is raised when attempting to insert an orphan. @@ -1661,13 +1662,13 @@ class DeleteOrphanTest(_base.MappedTest): ) def test_orphan_message(self): - class Base(_base.ComparableEntity): + class Base(fixtures.BasicEntity): pass class SubClass(Base): pass - class Parent(_base.ComparableEntity): + class Parent(fixtures.BasicEntity): pass mapper(Base, single, polymorphic_on=single.c.type, polymorphic_identity='base') diff --git a/test/orm/inheritance/test_concrete.py b/test/orm/inheritance/test_concrete.py index 6c427d44d3..4440865b0b 100644 --- a/test/orm/inheritance/test_concrete.py +++ b/test/orm/inheritance/test_concrete.py @@ -6,7 +6,7 @@ from sqlalchemy.orm import exc as orm_exc from test.lib import * import sqlalchemy as sa from test.lib import testing -from test.orm import _base +from test.lib import fixtures from sqlalchemy.orm import attributes from test.lib.testing import eq_ from test.lib.schema import Table, Column @@ -64,7 +64,7 @@ class Company(object): pass -class ConcreteTest(_base.MappedTest): +class ConcreteTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -372,7 +372,7 @@ class ConcreteTest(_base.MappedTest): self.assert_sql_count(testing.db, go, 1) -class PropertyInheritanceTest(_base.MappedTest): +class PropertyInheritanceTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -630,7 +630,7 @@ class PropertyInheritanceTest(_base.MappedTest): eq_(merged_c1.some_dest.name, 'd2') eq_(merged_c1.some_dest_id, c1.some_dest_id) -class ManyToManyTest(_base.MappedTest): +class ManyToManyTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -692,7 +692,7 @@ class ManyToManyTest(_base.MappedTest): eq_(b1.related, [r1, r2]) -class ColKeysTest(_base.MappedTest): +class ColKeysTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): diff --git a/test/orm/inheritance/test_magazine.py b/test/orm/inheritance/test_magazine.py index 868bbdcfc6..70387477f6 100644 --- a/test/orm/inheritance/test_magazine.py +++ b/test/orm/inheritance/test_magazine.py @@ -3,7 +3,7 @@ from sqlalchemy.orm import * from test.lib import testing from test.lib.util import function_named -from test.orm import _base +from test.lib import fixtures from test.lib.schema import Table, Column class BaseObject(object): @@ -70,7 +70,7 @@ class ClassifiedPage(MagazinePage): pass -class MagazineTest(_base.MappedTest): +class MagazineTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): global publication_table, issue_table, location_table, location_name_table, magazine_table, \ diff --git a/test/orm/inheritance/test_manytomany.py b/test/orm/inheritance/test_manytomany.py index f5e3e63a17..1d5d8b297e 100644 --- a/test/orm/inheritance/test_manytomany.py +++ b/test/orm/inheritance/test_manytomany.py @@ -3,10 +3,10 @@ from sqlalchemy import * from sqlalchemy.orm import * from test.lib import testing -from test.orm import _base +from test.lib import fixtures -class InheritTest(_base.MappedTest): +class InheritTest(fixtures.MappedTest): """deals with inheritance and many-to-many relationships""" @classmethod def define_tables(cls, metadata): @@ -66,7 +66,7 @@ class InheritTest(_base.MappedTest): sess.flush() # TODO: put an assertion -class InheritTest2(_base.MappedTest): +class InheritTest2(fixtures.MappedTest): """deals with inheritance and many-to-many relationships""" @classmethod def define_tables(cls, metadata): @@ -140,7 +140,7 @@ class InheritTest2(_base.MappedTest): {'id':b.id, 'data':'barfoo', 'foos':(Foo, [{'id':f1.id,'data':'subfoo1'}, {'id':f2.id,'data':'subfoo2'}])}, ) -class InheritTest3(_base.MappedTest): +class InheritTest3(fixtures.MappedTest): """deals with inheritance and many-to-many relationships""" @classmethod def define_tables(cls, metadata): diff --git a/test/orm/inheritance/test_poly_linked_list.py b/test/orm/inheritance/test_poly_linked_list.py index db622920af..f876625875 100644 --- a/test/orm/inheritance/test_poly_linked_list.py +++ b/test/orm/inheritance/test_poly_linked_list.py @@ -1,12 +1,12 @@ from sqlalchemy import * from sqlalchemy.orm import * -from test.orm import _base +from test.lib import fixtures from test.lib import testing from test.lib.schema import Table, Column -class PolymorphicCircularTest(_base.MappedTest): +class PolymorphicCircularTest(fixtures.MappedTest): run_setup_mappers = 'once' @classmethod diff --git a/test/orm/inheritance/test_polymorph.py b/test/orm/inheritance/test_polymorph.py index 1282fbf157..d6b37fc59e 100644 --- a/test/orm/inheritance/test_polymorph.py +++ b/test/orm/inheritance/test_polymorph.py @@ -7,9 +7,10 @@ from sqlalchemy.orm import exc as orm_exc from sqlalchemy import exc as sa_exc from test.lib import Column, testing from test.lib.util import function_named -from test.orm import _fixtures, _base +from test.orm import _fixtures +from test.lib import fixtures -class Person(_base.ComparableEntity): +class Person(fixtures.ComparableEntity): pass class Engineer(Person): pass @@ -17,10 +18,10 @@ class Manager(Person): pass class Boss(Manager): pass -class Company(_base.ComparableEntity): +class Company(fixtures.ComparableEntity): pass -class PolymorphTest(_base.MappedTest): +class PolymorphTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): global companies, people, engineers, managers, boss diff --git a/test/orm/inheritance/test_polymorph2.py b/test/orm/inheritance/test_polymorph2.py index 8f707c1e8b..7b21278af6 100644 --- a/test/orm/inheritance/test_polymorph2.py +++ b/test/orm/inheritance/test_polymorph2.py @@ -7,9 +7,10 @@ from sqlalchemy import * from sqlalchemy import util from sqlalchemy.orm import * -from test.lib import TestBase, AssertsExecutionResults, testing +from test.lib import AssertsExecutionResults, testing from test.lib.util import function_named -from test.orm import _base, _fixtures +from test.lib import fixtures +from test.orm import _fixtures from test.lib.testing import eq_ from test.lib.schema import Table, Column @@ -20,7 +21,7 @@ class AttrSettable(object): return self.__class__.__name__ + "(%s)" % (hex(id(self))) -class RelationshipTest1(_base.MappedTest): +class RelationshipTest1(fixtures.MappedTest): """test self-referential relationships on polymorphic mappers""" @classmethod def define_tables(cls, metadata): @@ -100,7 +101,7 @@ class RelationshipTest1(_base.MappedTest): print p, m, m.employee assert m.employee is p -class RelationshipTest2(_base.MappedTest): +class RelationshipTest2(fixtures.MappedTest): """test self-referential relationships on polymorphic mappers""" @classmethod def define_tables(cls, metadata): @@ -196,7 +197,7 @@ class RelationshipTest2(_base.MappedTest): if usedata: assert m.data.data == 'ms data' -class RelationshipTest3(_base.MappedTest): +class RelationshipTest3(fixtures.MappedTest): """test self-referential relationships on polymorphic mappers""" @classmethod def define_tables(cls, metadata): @@ -303,7 +304,7 @@ for jointype in ["join1", "join2", "join3", "join4"]: setattr(RelationshipTest3, func.__name__, func) del func -class RelationshipTest4(_base.MappedTest): +class RelationshipTest4(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): global people, engineers, managers, cars @@ -416,7 +417,7 @@ class RelationshipTest4(_base.MappedTest): c = s.join("employee").filter(Person.name=="E4")[0] assert c.car_id==car1.car_id -class RelationshipTest5(_base.MappedTest): +class RelationshipTest5(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): global people, engineers, managers, cars @@ -477,7 +478,7 @@ class RelationshipTest5(_base.MappedTest): assert carlist[0].manager is None assert carlist[1].manager.person_id == car2.manager.person_id -class RelationshipTest6(_base.MappedTest): +class RelationshipTest6(fixtures.MappedTest): """test self-referential relationships on a single joined-table inheritance mapper""" @classmethod def define_tables(cls, metadata): @@ -521,7 +522,7 @@ class RelationshipTest6(_base.MappedTest): m2 = sess.query(Manager).get(m2.person_id) assert m.colleague is m2 -class RelationshipTest7(_base.MappedTest): +class RelationshipTest7(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): global people, engineers, managers, cars, offroad_cars @@ -622,7 +623,7 @@ class RelationshipTest7(_base.MappedTest): for p in r: assert p.car_id == p.car.car_id -class RelationshipTest8(_base.MappedTest): +class RelationshipTest8(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): global taggable, users @@ -637,7 +638,7 @@ class RelationshipTest8(_base.MappedTest): ) def test_selfref_onjoined(self): - class Taggable(_base.ComparableEntity): + class Taggable(fixtures.ComparableEntity): pass class User(Taggable): @@ -668,7 +669,7 @@ class RelationshipTest8(_base.MappedTest): [User(data='u1'), Taggable(owner=User(data='u1'))] ) -class GenerativeTest(TestBase, AssertsExecutionResults): +class GenerativeTest(fixtures.TestBase, AssertsExecutionResults): @classmethod def setup_class(cls): # cars---owned by--- people (abstract) --- has a --- status @@ -796,7 +797,7 @@ class GenerativeTest(TestBase, AssertsExecutionResults): r = session.query(Person).filter(exists([1], Car.owner==Person.person_id)) eq_(str(list(r)), "[Engineer E4, field X, status Status dead]") -class MultiLevelTest(_base.MappedTest): +class MultiLevelTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): global table_Employee, table_Engineer, table_Manager @@ -874,7 +875,7 @@ class MultiLevelTest(_base.MappedTest): assert set(session.query( Engineer).all()) == set([b,c]) assert session.query( Manager).all() == [c] -class ManyToManyPolyTest(_base.MappedTest): +class ManyToManyPolyTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): global base_item_table, item_table, base_item_collection_table, collection_table @@ -925,7 +926,7 @@ class ManyToManyPolyTest(_base.MappedTest): class_mapper(BaseItem) -class CustomPKTest(_base.MappedTest): +class CustomPKTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): global t1, t2 @@ -1009,7 +1010,7 @@ class CustomPKTest(_base.MappedTest): ot1.data = 'hi' sess.flush() -class InheritingEagerTest(_base.MappedTest): +class InheritingEagerTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): global people, employees, tags, peopleTags @@ -1037,14 +1038,14 @@ class InheritingEagerTest(_base.MappedTest): def test_basic(self): """test that Query uses the full set of mapper._eager_loaders when generating SQL""" - class Person(_base.ComparableEntity): + class Person(fixtures.ComparableEntity): pass class Employee(Person): def __init__(self, name='bob'): self.name = name - class Tag(_base.ComparableEntity): + class Tag(fixtures.ComparableEntity): def __init__(self, label): self.label = label @@ -1071,7 +1072,7 @@ class InheritingEagerTest(_base.MappedTest): instance = session.query(Employee).filter_by(id=1).limit(1).first() assert len(instance.tags) == 2 -class MissingPolymorphicOnTest(_base.MappedTest): +class MissingPolymorphicOnTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): global tablea, tableb, tablec, tabled @@ -1094,9 +1095,9 @@ class MissingPolymorphicOnTest(_base.MappedTest): ) def test_polyon_col_setsup(self): - class A(_base.ComparableEntity): + class A(fixtures.ComparableEntity): pass - class B(_base.ComparableEntity): + class B(fixtures.ComparableEntity): pass class C(A): pass diff --git a/test/orm/inheritance/test_productspec.py b/test/orm/inheritance/test_productspec.py index a1ecf25629..615d2bb26c 100644 --- a/test/orm/inheritance/test_productspec.py +++ b/test/orm/inheritance/test_productspec.py @@ -3,10 +3,10 @@ from sqlalchemy import * from sqlalchemy.orm import * from test.lib import testing -from test.orm import _base +from test.lib import fixtures from test.lib.schema import Table, Column -class InheritTest(_base.MappedTest): +class InheritTest(fixtures.MappedTest): """tests some various inheritance round trips involving a particular set of polymorphic inheritance relationships""" @classmethod def define_tables(cls, metadata): diff --git a/test/orm/inheritance/test_query.py b/test/orm/inheritance/test_query.py index f0cf24d62d..23052f9977 100644 --- a/test/orm/inheritance/test_query.py +++ b/test/orm/inheritance/test_query.py @@ -7,14 +7,15 @@ from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.engine import default from test.lib import AssertsCompiledSQL, testing -from test.orm import _base, _fixtures +from test.lib import fixtures +from test.orm import _fixtures from test.lib.testing import eq_ from test.lib.schema import Table, Column -class Company(_base.ComparableEntity): +class Company(fixtures.ComparableEntity): pass -class Person(_base.ComparableEntity): +class Person(fixtures.ComparableEntity): pass class Engineer(Person): pass @@ -23,14 +24,14 @@ class Manager(Person): class Boss(Manager): pass -class Machine(_base.ComparableEntity): +class Machine(fixtures.ComparableEntity): pass -class Paperwork(_base.ComparableEntity): +class Paperwork(fixtures.ComparableEntity): pass def _produce_test(select_type): - class PolymorphicQueryTest(_base.MappedTest, AssertsCompiledSQL): + class PolymorphicQueryTest(fixtures.MappedTest, AssertsCompiledSQL): run_inserts = 'once' run_setup_mappers = 'once' run_deletes = None @@ -907,7 +908,7 @@ for select_type in ('', 'Polymorphic', 'Unions', 'AliasedJoins', 'Joins'): del testclass -class SelfReferentialTestJoinedToBase(_base.MappedTest): +class SelfReferentialTestJoinedToBase(fixtures.MappedTest): run_setup_mappers = 'once' @classmethod @@ -968,7 +969,7 @@ class SelfReferentialTestJoinedToBase(_base.MappedTest): sess.query(Engineer).join('reports_to', aliased=True).filter(Person.name=='dogbert').first(), Engineer(name='dilbert')) -class SelfReferentialJ2JTest(_base.MappedTest): +class SelfReferentialJ2JTest(fixtures.MappedTest): run_setup_mappers = 'once' @classmethod @@ -1084,7 +1085,7 @@ class SelfReferentialJ2JTest(_base.MappedTest): -class M2MFilterTest(_base.MappedTest): +class M2MFilterTest(fixtures.MappedTest): run_setup_mappers = 'once' run_inserts = 'once' run_deletes = None @@ -1171,7 +1172,7 @@ class M2MFilterTest(_base.MappedTest): eq_(sess.query(Organization).filter(Organization.engineers.any(Engineer.name == 'e1')).all(), [Organization(name='org1')]) -class SelfReferentialM2MTest(_base.MappedTest, AssertsCompiledSQL): +class SelfReferentialM2MTest(fixtures.MappedTest, AssertsCompiledSQL): @classmethod def define_tables(cls, metadata): Table('secondary', metadata, @@ -1306,7 +1307,7 @@ class SelfReferentialM2MTest(_base.MappedTest, AssertsCompiledSQL): for row in session.query(Child1).options(subqueryload('left_child2')).all(): assert row.left_child2 -class EagerToSubclassTest(_base.MappedTest): +class EagerToSubclassTest(fixtures.MappedTest): """Test eager loads to subclass mappers""" run_setup_classes = 'once' @@ -1472,7 +1473,7 @@ class EagerToSubclassTest(_base.MappedTest): ) self.assert_sql_count(testing.db, go, 3) -class SubClassEagerToSubClassTest(_base.MappedTest): +class SubClassEagerToSubClassTest(fixtures.MappedTest): """Test joinedloads from subclass to subclass mappers""" run_setup_classes = 'once' diff --git a/test/orm/inheritance/test_selects.py b/test/orm/inheritance/test_selects.py index f06482b5ac..9758744ca2 100644 --- a/test/orm/inheritance/test_selects.py +++ b/test/orm/inheritance/test_selects.py @@ -3,10 +3,9 @@ from sqlalchemy.orm import * from test.lib import testing -from test.orm._base import MappedTest, ComparableEntity as Base +from test.lib import fixtures - -class InheritingSelectablesTest(MappedTest): +class InheritingSelectablesTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): global foo, bar, baz @@ -24,7 +23,7 @@ class InheritingSelectablesTest(MappedTest): testing.db.execute(foo.insert(), a='i am bar', b='bar') testing.db.execute(foo.insert(), a='also bar', b='bar') - class Foo(Base): pass + class Foo(fixtures.ComparableEntity): pass class Bar(Foo): pass class Baz(Foo): pass diff --git a/test/orm/inheritance/test_single.py b/test/orm/inheritance/test_single.py index 392c63d40b..694ba01690 100644 --- a/test/orm/inheritance/test_single.py +++ b/test/orm/inheritance/test_single.py @@ -4,11 +4,11 @@ from sqlalchemy.orm import * from test.lib import testing from test.orm import _fixtures -from test.orm import _base +from test.lib import fixtures from test.lib.schema import Table, Column -class SingleInheritanceTest(testing.AssertsCompiledSQL, _base.MappedTest): +class SingleInheritanceTest(testing.AssertsCompiledSQL, fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('employees', metadata, @@ -200,7 +200,7 @@ class SingleInheritanceTest(testing.AssertsCompiledSQL, _base.MappedTest): self.tables.reports, self.classes.Engineer) - class Report(_base.ComparableEntity): + class Report(fixtures.ComparableEntity): pass mapper(Report, reports, properties={ @@ -222,7 +222,7 @@ class SingleInheritanceTest(testing.AssertsCompiledSQL, _base.MappedTest): self.tables.reports, self.classes.Engineer) - class Report(_base.ComparableEntity): + class Report(fixtures.ComparableEntity): pass mapper(Report, reports, properties={ @@ -239,7 +239,7 @@ class SingleInheritanceTest(testing.AssertsCompiledSQL, _base.MappedTest): assert len(rq.join(Report.employee.of_type(Manager)).all()) == 1 assert len(rq.join(Report.employee.of_type(Engineer)).all()) == 0 -class RelationshipFromSingleTest(testing.AssertsCompiledSQL, _base.MappedTest): +class RelationshipFromSingleTest(testing.AssertsCompiledSQL, fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('employee', metadata, @@ -295,7 +295,7 @@ class RelationshipFromSingleTest(testing.AssertsCompiledSQL, _base.MappedTest): use_default_dialect=True ) -class RelationshipToSingleTest(_base.MappedTest): +class RelationshipToSingleTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('employees', metadata, @@ -463,7 +463,7 @@ class RelationshipToSingleTest(_base.MappedTest): ) go() -class SingleOnJoinedTest(_base.MappedTest): +class SingleOnJoinedTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): global persons_table, employees_table @@ -481,7 +481,7 @@ class SingleOnJoinedTest(_base.MappedTest): ) def test_single_on_joined(self): - class Person(_base.ComparableEntity): + class Person(fixtures.ComparableEntity): pass class Employee(Person): pass diff --git a/test/orm/test_association.py b/test/orm/test_association.py index b30db04f18..47d0b1ddc2 100644 --- a/test/orm/test_association.py +++ b/test/orm/test_association.py @@ -3,11 +3,11 @@ from test.lib import testing from sqlalchemy import Integer, String, ForeignKey from test.lib.schema import Table, Column from sqlalchemy.orm import mapper, relationship, create_session -from test.orm import _base +from test.lib import fixtures from test.lib.testing import eq_ -class AssociationTest(_base.MappedTest): +class AssociationTest(fixtures.MappedTest): run_setup_classes = 'once' run_setup_mappers = 'once' diff --git a/test/orm/test_assorted_eager.py b/test/orm/test_assorted_eager.py index 38253a3f7e..710149fe56 100644 --- a/test/orm/test_assorted_eager.py +++ b/test/orm/test_assorted_eager.py @@ -14,10 +14,10 @@ from sqlalchemy import Integer, String, ForeignKey from test.lib.schema import Table, Column from sqlalchemy.orm import mapper, relationship, backref, create_session from test.lib.testing import eq_ -from test.orm import _base +from test.lib import fixtures -class EagerTest(_base.MappedTest): +class EagerTest(fixtures.MappedTest): run_deletes = None run_inserts = "once" run_setup_mappers = "once" @@ -234,7 +234,7 @@ class EagerTest(_base.MappedTest): eq_(result, [u'3 Some Category']) -class EagerTest2(_base.MappedTest): +class EagerTest2(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('left', metadata, @@ -306,7 +306,7 @@ class EagerTest2(_base.MappedTest): obj = session.query(Left).filter_by(data='l1').one() -class EagerTest3(_base.MappedTest): +class EagerTest3(fixtures.MappedTest): """Eager loading combined with nested SELECT statements, functions, and aggregates.""" @classmethod @@ -397,7 +397,7 @@ class EagerTest3(_base.MappedTest): eq_(verify_result, arb_result) -class EagerTest4(_base.MappedTest): +class EagerTest4(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -454,7 +454,7 @@ class EagerTest4(_base.MappedTest): assert q[0] is d2 -class EagerTest5(_base.MappedTest): +class EagerTest5(fixtures.MappedTest): """Construction of AliasedClauses for the same eager load property but different parent mappers, due to inheritance.""" @classmethod @@ -548,7 +548,7 @@ class EagerTest5(_base.MappedTest): assert len([c for c in d2.comments]) == 1 -class EagerTest6(_base.MappedTest): +class EagerTest6(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -625,7 +625,7 @@ class EagerTest6(_base.MappedTest): x.inheritedParts -class EagerTest7(_base.MappedTest): +class EagerTest7(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('companies', metadata, @@ -711,7 +711,7 @@ class EagerTest7(_base.MappedTest): -class EagerTest8(_base.MappedTest): +class EagerTest8(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -763,7 +763,7 @@ class EagerTest8(_base.MappedTest): @classmethod def setup_classes(cls): - class Task_Type(cls.Basic): + class Task_Type(cls.Comparable): pass class Joined(cls.Comparable): @@ -802,7 +802,7 @@ class EagerTest8(_base.MappedTest): Joined(id=1, title=u'task 1', props_cnt=0)) -class EagerTest9(_base.MappedTest): +class EagerTest9(fixtures.MappedTest): """Test the usage of query options to eagerly load specific paths. This relies upon the 'path' construct used by PropertyOption to relate diff --git a/test/orm/test_attributes.py b/test/orm/test_attributes.py index cc6017fa94..5c5afff89d 100644 --- a/test/orm/test_attributes.py +++ b/test/orm/test_attributes.py @@ -6,7 +6,7 @@ from sqlalchemy import exc as sa_exc from test.lib import * from test.lib.testing import eq_, ne_, assert_raises, \ assert_raises_message -from test.orm import _base +from test.lib import fixtures from test.lib.util import gc_collect, all_partial_orderings from sqlalchemy.util import cmp, jython, topological from sqlalchemy import event @@ -16,7 +16,7 @@ MyTest = None MyTest2 = None -class AttributesTest(_base.ORMTest): +class AttributesTest(fixtures.ORMTest): def setup(self): global MyTest, MyTest2 class MyTest(object): pass @@ -282,9 +282,9 @@ class AttributesTest(_base.ORMTest): """ - class Foo(_base.ComparableEntity): + class Foo(fixtures.BasicEntity): pass - class Bar(_base.ComparableEntity): + class Bar(fixtures.BasicEntity): pass class ReceiveEvents(AttributeExtension): @@ -373,9 +373,9 @@ class AttributesTest(_base.ORMTest): ne_(woc, wic) def test_extension_lazyload_assertion(self): - class Foo(_base.BasicEntity): + class Foo(fixtures.BasicEntity): pass - class Bar(_base.BasicEntity): + class Bar(fixtures.BasicEntity): pass class ReceiveEvents(AttributeExtension): @@ -589,9 +589,9 @@ class AttributesTest(_base.ORMTest): def test_lazyhistory(self): """tests that history functions work with lazy-loading attributes""" - class Foo(_base.BasicEntity): + class Foo(fixtures.BasicEntity): pass - class Bar(_base.BasicEntity): + class Bar(fixtures.BasicEntity): pass instrumentation.register_class(Foo) @@ -767,7 +767,7 @@ class AttributesTest(_base.ORMTest): except sa_exc.ArgumentError, e: assert False -class UtilTest(_base.ORMTest): +class UtilTest(fixtures.ORMTest): def test_helpers(self): class Foo(object): pass @@ -794,7 +794,7 @@ class UtilTest(_base.ORMTest): attributes.del_attribute(f1, "coll") assert "coll" not in f1.__dict__ -class BackrefTest(_base.ORMTest): +class BackrefTest(fixtures.ORMTest): def test_m2m(self): class Student(object):pass @@ -966,7 +966,7 @@ class BackrefTest(_base.ORMTest): # and this condition changes. assert c1 in p1.children -class PendingBackrefTest(_base.ORMTest): +class PendingBackrefTest(fixtures.ORMTest): def setup(self): global Post, Blog, called, lazy_load @@ -1090,10 +1090,10 @@ class PendingBackrefTest(_base.ORMTest): attributes.instance_state(p1).commit_all(attributes.instance_dict(p1)) assert b.posts == [Post("post 1")] -class HistoryTest(_base.ORMTest): +class HistoryTest(fixtures.ORMTest): def test_get_committed_value(self): - class Foo(_base.BasicEntity): + class Foo(fixtures.BasicEntity): pass instrumentation.register_class(Foo) @@ -1115,7 +1115,7 @@ class HistoryTest(_base.ORMTest): attributes.instance_dict(f)), 3) def test_scalar(self): - class Foo(_base.BasicEntity): + class Foo(fixtures.BasicEntity): pass instrumentation.register_class(Foo) @@ -1192,7 +1192,7 @@ class HistoryTest(_base.ORMTest): def test_mutable_scalar(self): - class Foo(_base.BasicEntity): + class Foo(fixtures.BasicEntity): pass instrumentation.register_class(Foo) @@ -1240,7 +1240,7 @@ class HistoryTest(_base.ORMTest): 'someattr'), ((), [{'foo': 'old'}], ())) def test_flag_modified(self): - class Foo(_base.BasicEntity): + class Foo(fixtures.BasicEntity): pass instrumentation.register_class(Foo) @@ -1276,10 +1276,10 @@ class HistoryTest(_base.ORMTest): 'someattr'), ([['b', 'c']], (), ())) def test_use_object(self): - class Foo(_base.BasicEntity): + class Foo(fixtures.BasicEntity): pass - class Bar(_base.BasicEntity): + class Bar(fixtures.BasicEntity): _state = None def __nonzero__(self): assert False @@ -1362,9 +1362,9 @@ class HistoryTest(_base.ORMTest): 'someattr'), (['two'], (), ())) def test_object_collections_set(self): - class Foo(_base.BasicEntity): + class Foo(fixtures.BasicEntity): pass - class Bar(_base.BasicEntity): + class Bar(fixtures.BasicEntity): def __nonzero__(self): assert False @@ -1421,9 +1421,9 @@ class HistoryTest(_base.ORMTest): 'someattr'), ((), [old], ())) def test_dict_collections(self): - class Foo(_base.BasicEntity): + class Foo(fixtures.BasicEntity): pass - class Bar(_base.BasicEntity): + class Bar(fixtures.BasicEntity): pass from sqlalchemy.orm.collections import attribute_mapped_collection @@ -1453,9 +1453,9 @@ class HistoryTest(_base.ORMTest): 'someattr')]), (set(), set([hi, there]), set())) def test_object_collections_mutate(self): - class Foo(_base.BasicEntity): + class Foo(fixtures.BasicEntity): pass - class Bar(_base.BasicEntity): + class Bar(fixtures.BasicEntity): pass instrumentation.register_class(Foo) @@ -1560,9 +1560,9 @@ class HistoryTest(_base.ORMTest): 'someattr'), ([], [], [hi, there, hi])) def test_collections_via_backref(self): - class Foo(_base.BasicEntity): + class Foo(fixtures.BasicEntity): pass - class Bar(_base.BasicEntity): + class Bar(fixtures.BasicEntity): pass instrumentation.register_class(Foo) @@ -1595,9 +1595,9 @@ class HistoryTest(_base.ORMTest): 'foo'), ([f1], (), ())) def test_lazy_backref_collections(self): - class Foo(_base.BasicEntity): + class Foo(fixtures.BasicEntity): pass - class Bar(_base.BasicEntity): + class Bar(fixtures.BasicEntity): pass lazy_load = [] @@ -1632,9 +1632,9 @@ class HistoryTest(_base.ORMTest): 'bars'), ((), [bar1, bar2, bar3], ())) def test_collections_via_lazyload(self): - class Foo(_base.BasicEntity): + class Foo(fixtures.BasicEntity): pass - class Bar(_base.BasicEntity): + class Bar(fixtures.BasicEntity): pass lazy_load = [] @@ -1674,7 +1674,7 @@ class HistoryTest(_base.ORMTest): 'bars'), ([bar2], [], [])) def test_scalar_via_lazyload(self): - class Foo(_base.BasicEntity): + class Foo(fixtures.BasicEntity): pass lazy_load = None @@ -1715,7 +1715,7 @@ class HistoryTest(_base.ORMTest): 'bar'), ([None], (), ['hi'])) def test_scalar_via_lazyload_with_active(self): - class Foo(_base.BasicEntity): + class Foo(fixtures.BasicEntity): pass lazy_load = None @@ -1757,9 +1757,9 @@ class HistoryTest(_base.ORMTest): 'bar'), ([None], (), ['hi'])) def test_scalar_object_via_lazyload(self): - class Foo(_base.BasicEntity): + class Foo(fixtures.BasicEntity): pass - class Bar(_base.BasicEntity): + class Bar(fixtures.BasicEntity): pass lazy_load = None @@ -1814,7 +1814,7 @@ class HistoryTest(_base.ORMTest): attributes.get_history, object(), 'foo', False ) -class ListenerTest(_base.ORMTest): +class ListenerTest(fixtures.ORMTest): def test_receive_changes(self): """test that Listeners can mutate the given value.""" diff --git a/test/orm/test_backref_mutations.py b/test/orm/test_backref_mutations.py index 9abc0df28e..5f3d3709c2 100644 --- a/test/orm/test_backref_mutations.py +++ b/test/orm/test_backref_mutations.py @@ -17,7 +17,8 @@ from sqlalchemy.orm import mapper, relationship, create_session, class_mapper, b from sqlalchemy.orm import attributes, exc as orm_exc from test.lib import testing from test.lib.testing import eq_ -from test.orm import _base, _fixtures +from test.lib import fixtures +from test.orm import _fixtures class O2MCollectionTest(_fixtures.FixtureTest): run_inserts = None diff --git a/test/orm/test_bind.py b/test/orm/test_bind.py index ef6c31b63a..00d9bb0942 100644 --- a/test/orm/test_bind.py +++ b/test/orm/test_bind.py @@ -5,10 +5,10 @@ from test.lib.schema import Column from sqlalchemy.orm import mapper, create_session import sqlalchemy as sa from test.lib import testing -from test.orm import _base +from test.lib import fixtures -class BindTest(_base.MappedTest): +class BindTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('test_table', metadata, diff --git a/test/orm/test_cascade.py b/test/orm/test_cascade.py index 279395ce82..89b3386710 100644 --- a/test/orm/test_cascade.py +++ b/test/orm/test_cascade.py @@ -8,10 +8,11 @@ from sqlalchemy.orm import mapper, relationship, create_session, \ from sqlalchemy.orm import attributes, exc as orm_exc from test.lib import testing from test.lib.testing import eq_ -from test.orm import _base, _fixtures +from test.lib import fixtures +from test.orm import _fixtures -class O2MCascadeDeleteOrphanTest(_base.MappedTest): +class O2MCascadeDeleteOrphanTest(fixtures.MappedTest): run_inserts = None @classmethod @@ -302,7 +303,7 @@ class O2MCascadeDeleteOrphanTest(_base.MappedTest): assert users.count().scalar() == 1 assert orders.count().scalar() == 0 -class O2MCascadeDeleteNoOrphanTest(_base.MappedTest): +class O2MCascadeDeleteNoOrphanTest(fixtures.MappedTest): run_inserts = None @classmethod @@ -982,7 +983,7 @@ class NoSaveCascadeBackrefTest(_fixtures.FixtureTest): assert k1 not in sess -class M2OCascadeDeleteOrphanTestOne(_base.MappedTest): +class M2OCascadeDeleteOrphanTestOne(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -1164,7 +1165,7 @@ class M2OCascadeDeleteOrphanTestOne(_base.MappedTest): eq_(sess.query(Pref).order_by(Pref.id).all(), [Pref(data="pref 1"), Pref(data="pref 3"), Pref(data="newpref")]) -class M2OCascadeDeleteOrphanTestTwo(_base.MappedTest): +class M2OCascadeDeleteOrphanTestTwo(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -1306,7 +1307,7 @@ class M2OCascadeDeleteOrphanTestTwo(_base.MappedTest): assert z.t3 is y assert x.t3 is None -class M2OCascadeDeleteNoOrphanTest(_base.MappedTest): +class M2OCascadeDeleteNoOrphanTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -1456,7 +1457,7 @@ class M2OCascadeDeleteNoOrphanTest(_base.MappedTest): -class M2MCascadeTest(_base.MappedTest): +class M2MCascadeTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('a', metadata, @@ -1769,7 +1770,7 @@ class NoBackrefCascadeTest(_fixtures.FixtureTest): sess.commit ) -class PendingOrphanTestSingleLevel(_base.MappedTest): +class PendingOrphanTestSingleLevel(fixtures.MappedTest): """Pending entities that are orphans""" @classmethod @@ -1899,7 +1900,7 @@ class PendingOrphanTestSingleLevel(_base.MappedTest): eq_(s.query(Address).all(), [Address(email_address='ad1')]) -class PendingOrphanTestTwoLevel(_base.MappedTest): +class PendingOrphanTestTwoLevel(fixtures.MappedTest): """test usages stated at http://article.gmane.org/gmane.comp.python.sqlalchemy.user/3085 @@ -1991,7 +1992,7 @@ class PendingOrphanTestTwoLevel(_base.MappedTest): assert i1 not in s assert a1 not in o1.items -class DoubleParentO2MOrphanTest(_base.MappedTest): +class DoubleParentO2MOrphanTest(fixtures.MappedTest): """Test orphan behavior on an entity that requires two parents via many-to-one (one-to-many collection.). @@ -2025,11 +2026,11 @@ class DoubleParentO2MOrphanTest(_base.MappedTest): """test the delete-orphan uow event for multiple delete-orphan parent relationships.""" - class Customer(_base.ComparableEntity): + class Customer(fixtures.ComparableEntity): pass - class Account(_base.ComparableEntity): + class Account(fixtures.ComparableEntity): pass - class SalesRep(_base.ComparableEntity): + class SalesRep(fixtures.ComparableEntity): pass mapper(Customer, customers) @@ -2069,11 +2070,11 @@ class DoubleParentO2MOrphanTest(_base.MappedTest): """test the delete-orphan uow event for multiple delete-orphan parent relationships.""" - class Customer(_base.ComparableEntity): + class Customer(fixtures.ComparableEntity): pass - class Account(_base.ComparableEntity): + class Account(fixtures.ComparableEntity): pass - class SalesRep(_base.ComparableEntity): + class SalesRep(fixtures.ComparableEntity): pass mapper(Customer, customers) @@ -2106,7 +2107,7 @@ class DoubleParentO2MOrphanTest(_base.MappedTest): 'Should expunge customer when both parents are gone' -class DoubleParentM2OOrphanTest(_base.MappedTest): +class DoubleParentM2OOrphanTest(fixtures.MappedTest): """Test orphan behavior on an entity that requires two parents via one-to-many (many-to-one reference to the orphan). @@ -2144,11 +2145,11 @@ class DoubleParentM2OOrphanTest(_base.MappedTest): """test that an entity can have two parent delete-orphan cascades, and persists normally.""" - class Address(_base.ComparableEntity): + class Address(fixtures.ComparableEntity): pass - class Home(_base.ComparableEntity): + class Home(fixtures.ComparableEntity): pass - class Business(_base.ComparableEntity): + class Business(fixtures.ComparableEntity): pass mapper(Address, addresses) @@ -2182,13 +2183,13 @@ class DoubleParentM2OOrphanTest(_base.MappedTest): cascades, and is detected as an orphan when saved without a parent.""" - class Address(_base.ComparableEntity): + class Address(fixtures.ComparableEntity): pass - class Home(_base.ComparableEntity): + class Home(fixtures.ComparableEntity): pass - class Business(_base.ComparableEntity): + class Business(fixtures.ComparableEntity): pass mapper(Address, addresses) @@ -2203,7 +2204,7 @@ class DoubleParentM2OOrphanTest(_base.MappedTest): session.add(a1) session.flush() -class CollectionAssignmentOrphanTest(_base.MappedTest): +class CollectionAssignmentOrphanTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('table_a', metadata, @@ -2219,9 +2220,9 @@ class CollectionAssignmentOrphanTest(_base.MappedTest): def test_basic(self): table_b, table_a = self.tables.table_b, self.tables.table_a - class A(_base.ComparableEntity): + class A(fixtures.ComparableEntity): pass - class B(_base.ComparableEntity): + class B(fixtures.ComparableEntity): pass mapper(A, table_a, properties={ @@ -2251,7 +2252,7 @@ class CollectionAssignmentOrphanTest(_base.MappedTest): eq_(sess.query(A).get(a1.id), A(name='a1', bs=[B(name='b1'), B(name='b2'), B(name='b3')])) -class O2MConflictTest(_base.MappedTest): +class O2MConflictTest(fixtures.MappedTest): """test that O2M dependency detects a change in parent, does the right thing, and updates the collection/attribute. @@ -2414,7 +2415,7 @@ class O2MConflictTest(_base.MappedTest): self._do_move_test(False) -class PartialFlushTest(_base.MappedTest): +class PartialFlushTest(fixtures.MappedTest): """test cascade behavior as it relates to object lists passed to flush().""" @classmethod def define_tables(cls, metadata): @@ -2442,9 +2443,9 @@ class PartialFlushTest(_base.MappedTest): def test_o2m_m2o(self): base, noninh_child = self.tables.base, self.tables.noninh_child - class Base(_base.ComparableEntity): + class Base(fixtures.ComparableEntity): pass - class Child(_base.ComparableEntity): + class Child(fixtures.ComparableEntity): pass mapper(Base, base, properties={ @@ -2497,7 +2498,7 @@ class PartialFlushTest(_base.MappedTest): """test ticket 1306""" - class Base(_base.ComparableEntity): + class Base(fixtures.ComparableEntity): pass class Parent(Base): pass diff --git a/test/orm/test_collection.py b/test/orm/test_collection.py index 44726297f8..7c1e7bc598 100644 --- a/test/orm/test_collection.py +++ b/test/orm/test_collection.py @@ -12,7 +12,7 @@ from test.lib.schema import Table, Column from sqlalchemy import util, exc as sa_exc from sqlalchemy.orm import create_session, mapper, relationship, \ attributes, instrumentation -from test.orm import _base +from test.lib import fixtures from test.lib.testing import eq_, assert_raises, assert_raises_message class Canary(sa.orm.interfaces.AttributeExtension): @@ -38,7 +38,7 @@ class Canary(sa.orm.interfaces.AttributeExtension): self.append(obj, value, None) return value -class CollectionsTest(_base.ORMTest): +class CollectionsTest(fixtures.ORMTest): class Entity(object): def __init__(self, a=None, b=None, c=None): self.a = a @@ -1408,7 +1408,7 @@ class CollectionsTest(_base.ORMTest): obj.attr[0] = e3 self.assert_(e3 in canary.data) -class DictHelpersTest(_base.MappedTest): +class DictHelpersTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -1613,7 +1613,7 @@ class DictHelpersTest(_base.MappedTest): collection_class = lambda: Ordered2(lambda v: (v.a, v.b)) self._test_composite_mapped(collection_class) -class CustomCollectionsTest(_base.MappedTest): +class CustomCollectionsTest(fixtures.MappedTest): """test the integration of collections with mapped classes.""" @classmethod @@ -1953,7 +1953,7 @@ class CustomCollectionsTest(_base.MappedTest): assert len(o) == 3 -class InstrumentationTest(_base.ORMTest): +class InstrumentationTest(fixtures.ORMTest): def test_uncooperative_descriptor_in_sweep(self): class DoNotTouch(object): def __get__(self, obj, owner): diff --git a/test/orm/test_compile.py b/test/orm/test_compile.py index 3294a853c4..7b63eab378 100644 --- a/test/orm/test_compile.py +++ b/test/orm/test_compile.py @@ -3,10 +3,10 @@ from sqlalchemy import exc as sa_exc from sqlalchemy.orm import * from test.lib import * from test.lib.testing import assert_raises_message -from test.orm import _base +from test.lib import fixtures -class CompileTest(_base.ORMTest): +class CompileTest(fixtures.ORMTest): """test various mapper compilation scenarios""" def teardown(self): diff --git a/test/orm/test_composites.py b/test/orm/test_composites.py index a47c772f3d..920c131274 100644 --- a/test/orm/test_composites.py +++ b/test/orm/test_composites.py @@ -11,10 +11,11 @@ from sqlalchemy.orm import attributes, \ composite, relationship, \ Session from test.lib.testing import eq_ -from test.orm import _base, _fixtures +from test.lib import fixtures +from test.orm import _fixtures -class PointTest(_base.MappedTest): +class PointTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('graphs', metadata, @@ -38,7 +39,7 @@ class PointTest(_base.MappedTest): def setup_mappers(cls): graphs, edges = cls.tables.graphs, cls.tables.edges - class Point(cls.Basic): + class Point(cls.Comparable): def __init__(self, x, y): self.x = x self.y = y @@ -53,9 +54,9 @@ class PointTest(_base.MappedTest): return not isinstance(other, Point) or \ not self.__eq__(other) - class Graph(cls.Basic): + class Graph(cls.Comparable): pass - class Edge(cls.Basic): + class Edge(cls.Comparable): def __init__(self, *args): if args: self.start, self.end = args @@ -219,7 +220,7 @@ class PointTest(_base.MappedTest): e = Edge() eq_(e.start, None) -class PrimaryKeyTest(_base.MappedTest): +class PrimaryKeyTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('graphs', metadata, @@ -233,7 +234,7 @@ class PrimaryKeyTest(_base.MappedTest): def setup_mappers(cls): graphs = cls.tables.graphs - class Version(cls.Basic): + class Version(cls.Comparable): def __init__(self, id, version): self.id = id self.version = version @@ -247,7 +248,7 @@ class PrimaryKeyTest(_base.MappedTest): def __ne__(self, other): return not self.__eq__(other) - class Graph(cls.Basic): + class Graph(cls.Comparable): def __init__(self, version): self.version = version @@ -311,7 +312,7 @@ class PrimaryKeyTest(_base.MappedTest): g2 = sess.query(Graph).filter_by(version=Version(2, None)).one() eq_(g.version, g2.version) -class DefaultsTest(_base.MappedTest): +class DefaultsTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -328,10 +329,10 @@ class DefaultsTest(_base.MappedTest): def setup_mappers(cls): foobars = cls.tables.foobars - class Foobar(cls.Basic): + class Foobar(cls.Comparable): pass - class FBComposite(cls.Basic): + class FBComposite(cls.Comparable): def __init__(self, x1, x2, x3, x4): self.x1 = x1 self.x2 = x2 @@ -384,7 +385,7 @@ class DefaultsTest(_base.MappedTest): assert f1.foob == FBComposite(2, 5, 15, None) -class MappedSelectTest(_base.MappedTest): +class MappedSelectTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('descriptions', metadata, @@ -408,13 +409,13 @@ class MappedSelectTest(_base.MappedTest): def setup_mappers(cls): values, descriptions = cls.tables.values, cls.tables.descriptions - class Descriptions(cls.Basic): + class Descriptions(cls.Comparable): pass - class Values(cls.Basic): + class Values(cls.Comparable): pass - class CustomValues(cls.Basic, list): + class CustomValues(cls.Comparable, list): def __init__(self, *args): self.extend(args) @@ -469,7 +470,7 @@ class MappedSelectTest(_base.MappedTest): [(1, 1, u'Red', u'5'), (2, 1, u'Blue', u'1')] ) -class ManyToOneTest(_base.MappedTest): +class ManyToOneTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('a', @@ -495,7 +496,7 @@ class ManyToOneTest(_base.MappedTest): class B(cls.Comparable): pass - class C(cls.Basic): + class C(cls.Comparable): def __init__(self, b1, b2): self.b1, self.b2 = b1, b2 @@ -543,7 +544,7 @@ class ManyToOneTest(_base.MappedTest): a2 ) -class ConfigurationTest(_base.MappedTest): +class ConfigurationTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('edge', metadata, @@ -557,7 +558,7 @@ class ConfigurationTest(_base.MappedTest): @classmethod def setup_mappers(cls): - class Point(cls.Basic): + class Point(cls.Comparable): def __init__(self, x, y): self.x = x self.y = y diff --git a/test/orm/test_cycles.py b/test/orm/test_cycles.py index 00c2e0aca0..bd85fa9710 100644 --- a/test/orm/test_cycles.py +++ b/test/orm/test_cycles.py @@ -12,10 +12,10 @@ from sqlalchemy.orm import mapper, relationship, backref, \ create_session, sessionmaker from test.lib.testing import eq_ from test.lib.assertsql import RegexSQL, ExactSQL, CompiledSQL, AllOf -from test.orm import _base +from test.lib import fixtures -class SelfReferentialTest(_base.MappedTest): +class SelfReferentialTest(fixtures.MappedTest): """A self-referential mapper with an additional list of child objects.""" @classmethod @@ -134,7 +134,7 @@ class SelfReferentialTest(_base.MappedTest): sess.expire_all() assert c2.parent_c1 is None -class SelfReferentialNoPKTest(_base.MappedTest): +class SelfReferentialNoPKTest(fixtures.MappedTest): """A self-referential relationship that joins on a column other than the primary key column""" @classmethod @@ -191,7 +191,7 @@ class SelfReferentialNoPKTest(_base.MappedTest): eq_(t.parent.uuid, t1.uuid) -class InheritTestOne(_base.MappedTest): +class InheritTestOne(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table("parent", metadata, @@ -260,7 +260,7 @@ class InheritTestOne(_base.MappedTest): session.flush() -class InheritTestTwo(_base.MappedTest): +class InheritTestTwo(fixtures.MappedTest): """ The fix in BiDirectionalManyToOneTest raised this issue, regarding the @@ -321,7 +321,7 @@ class InheritTestTwo(_base.MappedTest): sess.flush() -class BiDirectionalManyToOneTest(_base.MappedTest): +class BiDirectionalManyToOneTest(fixtures.MappedTest): run_define_tables = 'each' @classmethod @@ -421,7 +421,7 @@ class BiDirectionalManyToOneTest(_base.MappedTest): sess.flush() -class BiDirectionalOneToManyTest(_base.MappedTest): +class BiDirectionalOneToManyTest(fixtures.MappedTest): """tests two mappers with a one-to-many relationship to each other.""" run_define_tables = 'each' @@ -474,7 +474,7 @@ class BiDirectionalOneToManyTest(_base.MappedTest): sess.flush() -class BiDirectionalOneToManyTest2(_base.MappedTest): +class BiDirectionalOneToManyTest2(fixtures.MappedTest): """Two mappers with a one-to-many relationship to each other, with a second one-to-many on one of the mappers""" @@ -554,7 +554,7 @@ class BiDirectionalOneToManyTest2(_base.MappedTest): sess.delete(c) sess.flush() -class OneToManyManyToOneTest(_base.MappedTest): +class OneToManyManyToOneTest(fixtures.MappedTest): """ Tests two mappers, one has a one-to-many on the other mapper, the other @@ -581,10 +581,10 @@ class OneToManyManyToOneTest(_base.MappedTest): @classmethod def setup_classes(cls): - class Person(cls.Comparable): + class Person(cls.Basic): pass - class Ball(cls.Comparable): + class Ball(cls.Basic): pass def test_cycle(self): @@ -812,7 +812,7 @@ class OneToManyManyToOneTest(_base.MappedTest): ) -class SelfReferentialPostUpdateTest(_base.MappedTest): +class SelfReferentialPostUpdateTest(fixtures.MappedTest): """Post_update on a single self-referential mapper. @@ -961,7 +961,7 @@ class SelfReferentialPostUpdateTest(_base.MappedTest): cats.prev_sibling = None session.flush() -class SelfReferentialPostUpdateTest2(_base.MappedTest): +class SelfReferentialPostUpdateTest2(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -1009,7 +1009,7 @@ class SelfReferentialPostUpdateTest2(_base.MappedTest): assert f2.foo is f1 -class SelfReferentialPostUpdateTest3(_base.MappedTest): +class SelfReferentialPostUpdateTest3(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('parent', metadata, @@ -1077,7 +1077,7 @@ class SelfReferentialPostUpdateTest3(_base.MappedTest): p2.child = None session.flush() -class PostUpdateBatchingTest(_base.MappedTest): +class PostUpdateBatchingTest(fixtures.MappedTest): """test that lots of post update cols batch together into a single UPDATE.""" @classmethod diff --git a/test/orm/test_defaults.py b/test/orm/test_defaults.py index 4dd9da5d39..8063d92b71 100644 --- a/test/orm/test_defaults.py +++ b/test/orm/test_defaults.py @@ -4,11 +4,11 @@ from sqlalchemy import Integer, String, ForeignKey, event from test.lib import testing from test.lib.schema import Table, Column from sqlalchemy.orm import mapper, relationship, create_session -from test.orm import _base +from test.lib import fixtures from test.lib.testing import eq_ -class TriggerDefaultsTest(_base.MappedTest): +class TriggerDefaultsTest(fixtures.MappedTest): __requires__ = ('row_triggers',) @classmethod @@ -78,7 +78,7 @@ class TriggerDefaultsTest(_base.MappedTest): @classmethod def setup_classes(cls): - class Default(cls.Basic): + class Default(cls.Comparable): pass @classmethod @@ -124,7 +124,7 @@ class TriggerDefaultsTest(_base.MappedTest): eq_(d1.col3, 'up') eq_(d1.col4, 'up') -class ExcludedDefaultsTest(_base.MappedTest): +class ExcludedDefaultsTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): dt = Table('dt', metadata, @@ -135,7 +135,7 @@ class ExcludedDefaultsTest(_base.MappedTest): def test_exclude(self): dt = self.tables.dt - class Foo(_base.ComparableEntity): + class Foo(fixtures.BasicEntity): pass mapper(Foo, dt, exclude_properties=('col1',)) diff --git a/test/orm/test_deprecations.py b/test/orm/test_deprecations.py index f313aecec5..03240e95c4 100644 --- a/test/orm/test_deprecations.py +++ b/test/orm/test_deprecations.py @@ -10,10 +10,10 @@ from sqlalchemy import Integer, String, ForeignKey, func from test.lib.schema import Table from test.lib.schema import Column from sqlalchemy.orm import mapper, relationship, relation, create_session, sessionmaker -from test.orm import _base +from test.lib import fixtures -class QueryAlternativesTest(_base.MappedTest): +class QueryAlternativesTest(fixtures.MappedTest): '''Collects modern idioms for Queries The docstring for each test case serves as miniature documentation about diff --git a/test/orm/test_descriptor.py b/test/orm/test_descriptor.py index 3ef4afa7f1..c306ebd05c 100644 --- a/test/orm/test_descriptor.py +++ b/test/orm/test_descriptor.py @@ -5,7 +5,7 @@ from sqlalchemy.sql import column from sqlalchemy import Column, Integer, func, String from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.util import partial -from test.orm import _base +from test.lib import fixtures from test.lib.testing import eq_ class TestDescriptor(descriptor_props.DescriptorProperty): @@ -20,7 +20,7 @@ class TestDescriptor(descriptor_props.DescriptorProperty): else: self._comparator_factory = lambda mapper: None -class DescriptorInstrumentationTest(_base.ORMTest): +class DescriptorInstrumentationTest(fixtures.ORMTest): def _fixture(self): Base = declarative_base() diff --git a/test/orm/test_dynamic.py b/test/orm/test_dynamic.py index 7e253d033c..4cd4e94d1f 100644 --- a/test/orm/test_dynamic.py +++ b/test/orm/test_dynamic.py @@ -7,7 +7,8 @@ from test.lib.schema import Table, Column from sqlalchemy.orm import mapper, relationship, create_session, Query, attributes from sqlalchemy.orm.dynamic import AppenderMixin from test.lib.testing import eq_, AssertsCompiledSQL, assert_raises_message, assert_raises -from test.orm import _base, _fixtures +from test.lib import fixtures +from test.orm import _fixtures class DynamicTest(_fixtures.FixtureTest, AssertsCompiledSQL): @@ -661,7 +662,7 @@ class SessionTest(_fixtures.FixtureTest): def test_backref_savead(self): self._backref_test(False, False) -class DontDereferenceTest(_base.MappedTest): +class DontDereferenceTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('users', metadata, diff --git a/test/orm/test_eager_relations.py b/test/orm/test_eager_relations.py index e16673eb77..38c9e0d0af 100644 --- a/test/orm/test_eager_relations.py +++ b/test/orm/test_eager_relations.py @@ -13,7 +13,8 @@ from sqlalchemy.orm import mapper, relationship, create_session, \ from test.lib.testing import eq_, assert_raises, \ assert_raises_message from test.lib.assertsql import CompiledSQL -from test.orm import _base, _fixtures +from test.lib import fixtures +from test.orm import _fixtures from sqlalchemy.util import OrderedDict as odict import datetime @@ -1436,7 +1437,7 @@ class AddEntityTest(_fixtures.FixtureTest): eq_(ret, self._assert_result()) self.assert_sql_count(testing.db, go, 1) -class OrderBySecondaryTest(_base.MappedTest): +class OrderBySecondaryTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('m2m', metadata, @@ -1477,8 +1478,8 @@ class OrderBySecondaryTest(_base.MappedTest): self.tables.m2m, self.tables.b) - class A(_base.ComparableEntity):pass - class B(_base.ComparableEntity):pass + class A(fixtures.ComparableEntity):pass + class B(fixtures.ComparableEntity):pass mapper(A, a, properties={ 'bs':relationship(B, secondary=m2m, lazy='joined', order_by=m2m.c.id) @@ -1492,7 +1493,7 @@ class OrderBySecondaryTest(_base.MappedTest): ]) -class SelfReferentialEagerTest(_base.MappedTest): +class SelfReferentialEagerTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('nodes', metadata, @@ -1504,7 +1505,7 @@ class SelfReferentialEagerTest(_base.MappedTest): def test_basic(self): nodes = self.tables.nodes - class Node(_base.ComparableEntity): + class Node(fixtures.ComparableEntity): def append(self, node): self.children.append(node) @@ -1555,7 +1556,7 @@ class SelfReferentialEagerTest(_base.MappedTest): def test_lazy_fallback_doesnt_affect_eager(self): nodes = self.tables.nodes - class Node(_base.ComparableEntity): + class Node(fixtures.ComparableEntity): def append(self, node): self.children.append(node) @@ -1597,7 +1598,7 @@ class SelfReferentialEagerTest(_base.MappedTest): def test_with_deferred(self): nodes = self.tables.nodes - class Node(_base.ComparableEntity): + class Node(fixtures.ComparableEntity): def append(self, node): self.children.append(node) @@ -1640,7 +1641,7 @@ class SelfReferentialEagerTest(_base.MappedTest): def test_options(self): nodes = self.tables.nodes - class Node(_base.ComparableEntity): + class Node(fixtures.ComparableEntity): def append(self, node): self.children.append(node) @@ -1689,7 +1690,7 @@ class SelfReferentialEagerTest(_base.MappedTest): def test_no_depth(self): nodes = self.tables.nodes - class Node(_base.ComparableEntity): + class Node(fixtures.ComparableEntity): def append(self, node): self.children.append(node) @@ -1720,7 +1721,7 @@ class SelfReferentialEagerTest(_base.MappedTest): ]), d) self.assert_sql_count(testing.db, go, 3) -class MixedSelfReferentialEagerTest(_base.MappedTest): +class MixedSelfReferentialEagerTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('a_table', metadata, @@ -1800,7 +1801,7 @@ class MixedSelfReferentialEagerTest(_base.MappedTest): ) self.assert_sql_count(testing.db, go, 1) -class SelfReferentialM2MEagerTest(_base.MappedTest): +class SelfReferentialM2MEagerTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('widget', metadata, @@ -1817,7 +1818,7 @@ class SelfReferentialM2MEagerTest(_base.MappedTest): def test_basic(self): widget, widget_rel = self.tables.widget, self.tables.widget_rel - class Widget(_base.ComparableEntity): + class Widget(fixtures.ComparableEntity): pass mapper(Widget, widget, properties={ @@ -2004,7 +2005,7 @@ class MixedEntitiesTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL): dialect=DefaultDialect() ) -class CyclicalInheritingEagerTest(_base.MappedTest): +class CyclicalInheritingEagerTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -2045,7 +2046,7 @@ class CyclicalInheritingEagerTest(_base.MappedTest): # testing a particular endless loop condition in eager join setup create_session().query(SubT).all() -class SubqueryTest(_base.MappedTest): +class SubqueryTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('users_table', metadata, @@ -2075,12 +2076,12 @@ class SubqueryTest(_base.MappedTest): that type. """ - class User(_base.ComparableEntity): + class User(fixtures.ComparableEntity): @property def prop_score(self): return sum([tag.prop_score for tag in self.tags]) - class Tag(_base.ComparableEntity): + class Tag(fixtures.ComparableEntity): @property def prop_score(self): return self.score1 * self.score2 @@ -2129,7 +2130,7 @@ class SubqueryTest(_base.MappedTest): for t in (tags_table, users_table): t.delete().execute() -class CorrelatedSubqueryTest(_base.MappedTest): +class CorrelatedSubqueryTest(fixtures.MappedTest): """tests for #946, #947, #948. The "users" table is joined to "stuff", and the relationship @@ -2214,10 +2215,10 @@ class CorrelatedSubqueryTest(_base.MappedTest): def _do_test(self, labeled, ondate, aliasstuff): stuff, users = self.tables.stuff, self.tables.users - class User(_base.ComparableEntity): + class User(fixtures.ComparableEntity): pass - class Stuff(_base.ComparableEntity): + class Stuff(fixtures.ComparableEntity): pass mapper(Stuff, stuff) diff --git a/test/orm/test_evaluator.py b/test/orm/test_evaluator.py index 7679c54599..f632561f1f 100644 --- a/test/orm/test_evaluator.py +++ b/test/orm/test_evaluator.py @@ -6,7 +6,7 @@ from test.lib.schema import Table from test.lib.schema import Column from sqlalchemy.orm import mapper, create_session from test.lib.testing import eq_ -from test.orm import _base +from test.lib import fixtures from sqlalchemy import and_, or_, not_ from sqlalchemy.orm import evaluator @@ -21,7 +21,7 @@ def eval_eq(clause, testcases=None): testeval(an_obj, result) return testeval -class EvaluateTest(_base.MappedTest): +class EvaluateTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('users', metadata, @@ -30,7 +30,7 @@ class EvaluateTest(_base.MappedTest): @classmethod def setup_classes(cls): - class User(cls.Comparable): + class User(cls.Basic): pass @classmethod diff --git a/test/orm/test_events.py b/test/orm/test_events.py index 831fb4a118..58c7bf4626 100644 --- a/test/orm/test_events.py +++ b/test/orm/test_events.py @@ -9,7 +9,8 @@ from sqlalchemy.orm import mapper, relationship, \ Session, sessionmaker from sqlalchemy.orm.instrumentation import ClassManager from test.lib.testing import eq_ -from test.orm import _base, _fixtures +from test.lib import fixtures +from test.orm import _fixtures from sqlalchemy import event @@ -950,7 +951,7 @@ class MapperExtensionTest(_fixtures.FixtureTest): assert len(m.dispatch.before_insert) == 1 -class AttributeExtensionTest(_base.MappedTest): +class AttributeExtensionTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('t1', @@ -976,7 +977,7 @@ class AttributeExtensionTest(_base.MappedTest): ext_msg.append("Ex2 %r" % value) return "ex2" + value - class A(_base.BasicEntity): + class A(fixtures.BasicEntity): pass class B(A): pass diff --git a/test/orm/test_expire.py b/test/orm/test_expire.py index e82fa80818..310f6472ed 100644 --- a/test/orm/test_expire.py +++ b/test/orm/test_expire.py @@ -10,7 +10,8 @@ from test.lib.schema import Column from sqlalchemy.orm import mapper, relationship, create_session, \ attributes, deferred, exc as orm_exc, defer, undefer,\ strategies, state, lazyload, backref, Session -from test.orm import _base, _fixtures +from test.lib import fixtures +from test.orm import _fixtures class ExpireTest(_fixtures.FixtureTest): @@ -959,7 +960,7 @@ class ExpireTest(_fixtures.FixtureTest): -class PolymorphicExpireTest(_base.MappedTest): +class PolymorphicExpireTest(fixtures.MappedTest): run_inserts = 'once' run_deletes = None @@ -980,7 +981,7 @@ class PolymorphicExpireTest(_base.MappedTest): @classmethod def setup_classes(cls): - class Person(cls.Comparable): + class Person(cls.Basic): pass class Engineer(Person): pass diff --git a/test/orm/test_extendedattr.py b/test/orm/test_extendedattr.py index 2493f31fdd..df02043bfe 100644 --- a/test/orm/test_extendedattr.py +++ b/test/orm/test_extendedattr.py @@ -8,7 +8,7 @@ from sqlalchemy.orm.instrumentation import is_instrumented from sqlalchemy.orm import clear_mappers from sqlalchemy.orm import InstrumentationManager from test.lib import * -from test.orm import _base +from test.lib import fixtures class MyTypesManager(InstrumentationManager): @@ -98,7 +98,7 @@ class MyClass(object): else: del self._goofy_dict[key] -class UserDefinedExtensionTest(_base.ORMTest): +class UserDefinedExtensionTest(fixtures.ORMTest): @classmethod def teardown_class(cls): clear_mappers() diff --git a/test/orm/test_froms.py b/test/orm/test_froms.py index 17b4c8816f..127faafd2c 100644 --- a/test/orm/test_froms.py +++ b/test/orm/test_froms.py @@ -14,7 +14,7 @@ from test.lib import testing, AssertsCompiledSQL, Column, engines from test.orm import _fixtures -from test.orm import _base +from test.lib import fixtures from sqlalchemy.orm.util import join, outerjoin, with_parent @@ -248,7 +248,7 @@ class FromSelfTest(QueryTest, AssertsCompiledSQL): ) -class AddEntityEquivalenceTest(_base.MappedTest, AssertsCompiledSQL): +class AddEntityEquivalenceTest(fixtures.MappedTest, AssertsCompiledSQL): run_setup_mappers = 'once' @classmethod @@ -1804,7 +1804,7 @@ class ExternalColumnsTest(QueryTest): eq_(o1.address.user.count, 1) self.assert_sql_count(testing.db, go, 1) -class TestOverlyEagerEquivalentCols(_base.MappedTest): +class TestOverlyEagerEquivalentCols(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): base = Table('base', metadata, @@ -1827,11 +1827,11 @@ class TestOverlyEagerEquivalentCols(_base.MappedTest): self.tables.sub2, self.tables.sub1) - class Base(_base.ComparableEntity): + class Base(fixtures.ComparableEntity): pass - class Sub1(_base.ComparableEntity): + class Sub1(fixtures.ComparableEntity): pass - class Sub2(_base.ComparableEntity): + class Sub2(fixtures.ComparableEntity): pass mapper(Base, base, properties={ diff --git a/test/orm/test_generative.py b/test/orm/test_generative.py index 35fc0e3971..d513fdcfd5 100644 --- a/test/orm/test_generative.py +++ b/test/orm/test_generative.py @@ -6,10 +6,11 @@ from test.lib.schema import Table from test.lib.schema import Column from sqlalchemy.orm import mapper, relationship, create_session from test.lib.testing import eq_ -from test.orm import _base, _fixtures +from test.lib import fixtures +from test.orm import _fixtures -class GenerativeQueryTest(_base.MappedTest): +class GenerativeQueryTest(fixtures.MappedTest): run_inserts = 'once' run_deletes = None @@ -153,7 +154,7 @@ class GenerativeQueryTest(_base.MappedTest): assert len(list(query.limit(10))) == 10 -class GenerativeTest2(_base.MappedTest): +class GenerativeTest2(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -281,7 +282,7 @@ class RelationshipsTest(_fixtures.FixtureTest): set(q.all())) -class CaseSensitiveTest(_base.MappedTest): +class CaseSensitiveTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): diff --git a/test/orm/test_instrumentation.py b/test/orm/test_instrumentation.py index 18dca8e45d..cb952b4b33 100644 --- a/test/orm/test_instrumentation.py +++ b/test/orm/test_instrumentation.py @@ -8,7 +8,7 @@ from test.lib.schema import Table from test.lib.schema import Column from test.lib.testing import eq_, ne_ from test.lib.util import decorator -from test.orm import _base +from test.lib import fixtures @decorator def modifies_instrumentation_finders(fn, *args, **kw): @@ -30,7 +30,7 @@ def with_lookup_strategy(strategy): return decorate -class InitTest(_base.ORMTest): +class InitTest(fixtures.ORMTest): def fixture(self): return Table('t', MetaData(), Column('id', Integer, primary_key=True), @@ -436,7 +436,7 @@ class InitTest(_base.ORMTest): assert o.o is Y.outofscope -class MapperInitTest(_base.ORMTest): +class MapperInitTest(fixtures.ORMTest): def fixture(self): return Table('t', MetaData(), @@ -464,7 +464,7 @@ class MapperInitTest(_base.ORMTest): # C is not mapped in the current implementation assert_raises(sa.orm.exc.UnmappedClassError, class_mapper, C) -class InstrumentationCollisionTest(_base.ORMTest): +class InstrumentationCollisionTest(fixtures.ORMTest): def test_none(self): class A(object): pass instrumentation.register_class(A) @@ -536,7 +536,7 @@ class InstrumentationCollisionTest(_base.ORMTest): assert_raises_message(TypeError, "multiple instrumentation implementations", instrumentation.register_class, B1) -class OnLoadTest(_base.ORMTest): +class OnLoadTest(fixtures.ORMTest): """Check that Events.load is not hit in regular attributes operations.""" def test_basic(self): @@ -565,7 +565,7 @@ class OnLoadTest(_base.ORMTest): instrumentation._install_lookup_strategy(util.symbol('native')) -class ExtendedEventsTest(_base.ORMTest): +class ExtendedEventsTest(fixtures.ORMTest): """Allow custom Events implementations.""" @modifies_instrumentation_finders @@ -584,7 +584,7 @@ class ExtendedEventsTest(_base.ORMTest): assert issubclass(manager.dispatch._parent_cls.__dict__['dispatch'].events, MyEvents) -class NativeInstrumentationTest(_base.ORMTest): +class NativeInstrumentationTest(fixtures.ORMTest): @with_lookup_strategy(sa.util.symbol('native')) def test_register_reserved_attribute(self): class T(object): pass @@ -623,7 +623,7 @@ class NativeInstrumentationTest(_base.ORMTest): assert_raises(KeyError, mapper, T, t) -class MiscTest(_base.ORMTest): +class MiscTest(fixtures.ORMTest): """Seems basic, but not directly covered elsewhere!""" def test_compileonattr(self): @@ -718,7 +718,7 @@ class MiscTest(_base.ORMTest): assert b in session, 'base: %s' % base -class FinderTest(_base.ORMTest): +class FinderTest(fixtures.ORMTest): def test_standard(self): class A(object): pass diff --git a/test/orm/test_joins.py b/test/orm/test_joins.py index 454c90a53e..6bac148c7a 100644 --- a/test/orm/test_joins.py +++ b/test/orm/test_joins.py @@ -14,7 +14,7 @@ from test.lib import testing, AssertsCompiledSQL, Column, engines from test.orm import _fixtures -from test.orm import _base +from test.lib import fixtures from sqlalchemy.orm.util import join, outerjoin, with_parent @@ -66,7 +66,7 @@ class QueryTest(_fixtures.FixtureTest): configure_mappers() -class InheritedJoinTest(_base.MappedTest, AssertsCompiledSQL): +class InheritedJoinTest(fixtures.MappedTest, AssertsCompiledSQL): run_setup_mappers = 'once' @classmethod @@ -1297,7 +1297,7 @@ class JoinTest(QueryTest, AssertsCompiledSQL): ) -class MultiplePathTest(_base.MappedTest, AssertsCompiledSQL): +class MultiplePathTest(fixtures.MappedTest, AssertsCompiledSQL): @classmethod def define_tables(cls, metadata): t1 = Table('t1', metadata, @@ -1344,7 +1344,7 @@ class MultiplePathTest(_base.MappedTest, AssertsCompiledSQL): ) -class SelfRefMixedTest(_base.MappedTest, AssertsCompiledSQL): +class SelfRefMixedTest(fixtures.MappedTest, AssertsCompiledSQL): run_setup_mappers = 'once' __dialect__ = default.DefaultDialect() @@ -1432,7 +1432,7 @@ class SelfRefMixedTest(_base.MappedTest, AssertsCompiledSQL): ) -class SelfReferentialTest(_base.MappedTest, AssertsCompiledSQL): +class SelfReferentialTest(fixtures.MappedTest, AssertsCompiledSQL): run_setup_mappers = 'once' run_inserts = 'once' run_deletes = None @@ -1783,7 +1783,7 @@ class SelfReferentialTest(_base.MappedTest, AssertsCompiledSQL): eq_(sess.query(Node).filter(Node.parent != n12).all(), [Node(data='n1'), Node(data='n11'), Node(data='n12'), Node(data='n13')]) -class SelfReferentialM2MTest(_base.MappedTest): +class SelfReferentialM2MTest(fixtures.MappedTest): run_setup_mappers = 'once' run_inserts = 'once' run_deletes = None diff --git a/test/orm/test_lazy_relations.py b/test/orm/test_lazy_relations.py index 8766dd6173..73748ad50b 100644 --- a/test/orm/test_lazy_relations.py +++ b/test/orm/test_lazy_relations.py @@ -12,7 +12,8 @@ from test.lib.schema import Table from test.lib.schema import Column from sqlalchemy.orm import mapper, relationship, create_session from test.lib.testing import eq_ -from test.orm import _base, _fixtures +from test.lib import fixtures +from test.orm import _fixtures class LazyTest(_fixtures.FixtureTest): @@ -507,7 +508,7 @@ class M2OGetTest(_fixtures.FixtureTest): assert ad3.user is None self.assert_sql_count(testing.db, go, 1) -class CorrelatedTest(_base.MappedTest): +class CorrelatedTest(fixtures.MappedTest): @classmethod def define_tables(self, meta): @@ -539,10 +540,10 @@ class CorrelatedTest(_base.MappedTest): def test_correlated_lazyload(self): stuff, user_t = self.tables.stuff, self.tables.user_t - class User(_base.ComparableEntity): + class User(fixtures.ComparableEntity): pass - class Stuff(_base.ComparableEntity): + class Stuff(fixtures.ComparableEntity): pass mapper(Stuff, stuff) diff --git a/test/orm/test_legacy_mutable.py b/test/orm/test_legacy_mutable.py index 5c65b720e4..af5c7d3768 100644 --- a/test/orm/test_legacy_mutable.py +++ b/test/orm/test_legacy_mutable.py @@ -15,9 +15,10 @@ from test.lib.schema import Table, Column from sqlalchemy.orm import mapper, create_session, Session, attributes from test.lib.testing import eq_, ne_ from test.lib.util import gc_collect -from test.orm import _base, _fixtures +from test.lib import fixtures +from test.orm import _fixtures -class MutableTypesTest(_base.MappedTest): +class MutableTypesTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -277,7 +278,7 @@ class MutableTypesTest(_base.MappedTest): self.sql_count_(1, go) -class PickledDictsTest(_base.MappedTest): +class PickledDictsTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): diff --git a/test/orm/test_load_on_fks.py b/test/orm/test_load_on_fks.py index f8a080f3f4..cb1e035387 100644 --- a/test/orm/test_load_on_fks.py +++ b/test/orm/test_load_on_fks.py @@ -2,8 +2,9 @@ from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base -from test.lib.testing import TestBase, eq_, AssertsExecutionResults, assert_raises +from test.lib.testing import eq_, AssertsExecutionResults, assert_raises from test.lib import testing +from test.lib import fixtures from sqlalchemy.orm.attributes import instance_state from sqlalchemy.orm.exc import FlushError from test.lib.schema import Table, Column @@ -11,7 +12,7 @@ from test.lib.schema import Table, Column engine = testing.db -class FlushOnPendingTest(AssertsExecutionResults, TestBase): +class FlushOnPendingTest(AssertsExecutionResults, fixtures.TestBase): def setUp(self): global Parent, Child, Base Base= declarative_base() @@ -57,7 +58,7 @@ class FlushOnPendingTest(AssertsExecutionResults, TestBase): assert p1.children == [] self.assert_sql_count(testing.db, go, 0) -class LoadOnFKsTest(AssertsExecutionResults, TestBase): +class LoadOnFKsTest(AssertsExecutionResults, fixtures.TestBase): def setUp(self): global Parent, Child, Base diff --git a/test/orm/test_manytomany.py b/test/orm/test_manytomany.py index e7dc1075fe..ffe5fa62b6 100644 --- a/test/orm/test_manytomany.py +++ b/test/orm/test_manytomany.py @@ -7,10 +7,10 @@ from test.lib.schema import Table from test.lib.schema import Column from sqlalchemy.orm import mapper, relationship, create_session, \ exc as orm_exc, sessionmaker -from test.orm import _base +from test.lib import fixtures -class M2MTest(_base.MappedTest): +class M2MTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('place', metadata, @@ -98,12 +98,12 @@ class M2MTest(_base.MappedTest): sa.orm.configure_mappers) def test_circular(self): + """test a many-to-many relationship from a table to itself.""" + place, Place, place_place = (self.tables.place, self.classes.Place, self.tables.place_place) - """test a many-to-many relationship from a table to itself.""" - mapper(Place, place, properties={ 'places': relationship( Place, @@ -152,12 +152,13 @@ class M2MTest(_base.MappedTest): sess.flush() def test_circular_mutation(self): + """Test that a mutation in a self-ref m2m of both sides succeeds.""" + + place, Place, place_place = (self.tables.place, self.classes.Place, self.tables.place_place) - """Test that a mutation in a self-ref m2m of both sides succeeds.""" - mapper(Place, place, properties={ 'child_places': relationship( Place, @@ -183,6 +184,9 @@ class M2MTest(_base.MappedTest): def test_double(self): + """test that a mapper can have two eager relationships to the same table, via + two different association tables. aliases are required.""" + place_input, transition, Transition, PlaceThingy, place, place_thingy, Place, place_output = (self.tables.place_input, self.tables.transition, self.classes.Transition, @@ -192,8 +196,6 @@ class M2MTest(_base.MappedTest): self.classes.Place, self.tables.place_output) - """test that a mapper can have two eager relationships to the same table, via - two different association tables. aliases are required.""" Place.mapper = mapper(Place, place, properties = { 'thingies':relationship(mapper(PlaceThingy, place_thingy), lazy='joined') @@ -229,7 +231,6 @@ class M2MTest(_base.MappedTest): self.tables.place, self.tables.place_output) - """tests a many-to-many backrefs""" Place.mapper = mapper(Place, place) Transition.mapper = mapper(Transition, transition, properties = dict( inputs = relationship(Place.mapper, place_output, lazy='select', backref='inputs'), @@ -304,7 +305,7 @@ class M2MTest(_base.MappedTest): sess.commit ) -class M2MTest2(_base.MappedTest): +class M2MTest2(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('student', metadata, @@ -408,7 +409,7 @@ class M2MTest2(_base.MappedTest): sess.flush() assert enroll.count().scalar() == 0 -class M2MTest3(_base.MappedTest): +class M2MTest3(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('c', metadata, @@ -460,7 +461,7 @@ class M2MTest3(_base.MappedTest): # TODO: seems like just a test for an ancient exception throw. # how about some data/inserts/queries/assertions for this one -class M2MTest4(_base.MappedTest): +class M2MTest4(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): table1 = Table("table1", metadata, @@ -483,9 +484,9 @@ class M2MTest4(_base.MappedTest): self.tables.table3, self.tables.table1) - class A(_base.ComparableEntity): + class A(fixtures.ComparableEntity): pass - class B(_base.ComparableEntity): + class B(fixtures.ComparableEntity): pass mapper(A, table1, properties={ diff --git a/test/orm/test_mapper.py b/test/orm/test_mapper.py index 85a4db67af..23f63a79c7 100644 --- a/test/orm/test_mapper.py +++ b/test/orm/test_mapper.py @@ -12,7 +12,8 @@ from sqlalchemy.orm import mapper, relationship, backref, \ column_property, composite, dynamic_loader, \ comparable_property, Session from test.lib.testing import eq_, AssertsCompiledSQL -from test.orm import _base, _fixtures +from test.lib import fixtures +from test.orm import _fixtures from test.lib.assertsql import CompiledSQL class MapperTest(_fixtures.FixtureTest): @@ -326,7 +327,7 @@ class MapperTest(_fixtures.FixtureTest): assert_col = [] - class User(_base.ComparableEntity): + class User(fixtures.ComparableEntity): def _get_name(self): assert_col.append(('get', self._name)) return self._name @@ -1332,7 +1333,7 @@ class MapperTest(_fixtures.FixtureTest): mapper(B, users) -class DocumentTest(testing.TestBase): +class DocumentTest(fixtures.TestBase): def test_doc_propagate(self): metadata = MetaData() @@ -1712,7 +1713,7 @@ class ValidatorTest(_fixtures.FixtureTest): def test_scalar(self): users = self.tables.users - class User(_base.ComparableEntity): + class User(fixtures.ComparableEntity): @validates('name') def validate_name(self, key, name): assert name != 'fred' @@ -1735,7 +1736,7 @@ class ValidatorTest(_fixtures.FixtureTest): self.tables.addresses, self.classes.Address) - class User(_base.ComparableEntity): + class User(fixtures.ComparableEntity): @validates('addresses') def validate_address(self, key, ad): assert '@' in ad.email_address @@ -2186,7 +2187,7 @@ class DeferredTest(_fixtures.FixtureTest): eq_(item.description, 'item 4') -class SecondaryOptionsTest(_base.MappedTest): +class SecondaryOptionsTest(fixtures.MappedTest): """test that the contains_eager() option doesn't bleed into a secondary load.""" run_inserts = 'once' @@ -2368,7 +2369,7 @@ class SecondaryOptionsTest(_base.MappedTest): ) -class DeferredPopulationTest(_base.MappedTest): +class DeferredPopulationTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table("thing", metadata, @@ -2517,7 +2518,7 @@ class NoLoadTest(_fixtures.FixtureTest): -class RequirementsTest(_base.MappedTest): +class RequirementsTest(fixtures.MappedTest): """Tests the contract for user classes.""" @classmethod @@ -2691,7 +2692,7 @@ class RequirementsTest(_base.MappedTest): h2.value = "Asdf" h2.value = "asdf asdf" # ding -class MagicNamesTest(_base.MappedTest): +class MagicNamesTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): diff --git a/test/orm/test_merge.py b/test/orm/test_merge.py index 96507387fd..6df45cb72a 100644 --- a/test/orm/test_merge.py +++ b/test/orm/test_merge.py @@ -9,7 +9,8 @@ from sqlalchemy.orm import mapper, relationship, create_session, PropComparator, from sqlalchemy.orm.collections import attribute_mapped_collection from sqlalchemy.orm.interfaces import MapperOption from test.lib.testing import eq_, ne_ -from test.orm import _base, _fixtures +from test.lib import fixtures +from test.orm import _fixtures from sqlalchemy import event from test.lib.schema import Table, Column @@ -1085,7 +1086,7 @@ class MergeTest(_fixtures.FixtureTest): eq_(ustate.load_options, set([opt2])) -class MutableMergeTest(_base.MappedTest): +class MutableMergeTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table("data", metadata, @@ -1095,7 +1096,7 @@ class MutableMergeTest(_base.MappedTest): @classmethod def setup_classes(cls): - class Data(cls.Comparable): + class Data(cls.Basic): pass def test_list(self): @@ -1114,7 +1115,7 @@ class MutableMergeTest(_base.MappedTest): -class CompositeNullPksTest(_base.MappedTest): +class CompositeNullPksTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table("data", metadata, @@ -1124,7 +1125,7 @@ class CompositeNullPksTest(_base.MappedTest): @classmethod def setup_classes(cls): - class Data(cls.Comparable): + class Data(cls.Basic): pass def test_merge_allow_partial(self): diff --git a/test/orm/test_naturalpks.py b/test/orm/test_naturalpks.py index e838d57e36..1488659654 100644 --- a/test/orm/test_naturalpks.py +++ b/test/orm/test_naturalpks.py @@ -11,9 +11,10 @@ from test.lib.schema import Table, Column from sqlalchemy.orm import mapper, relationship, create_session, backref, Session from sqlalchemy.orm.session import make_transient from test.lib.testing import eq_ -from test.orm import _base, _fixtures +from test.lib import fixtures +from test.orm import _fixtures -class NaturalPKTest(_base.MappedTest): +class NaturalPKTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -444,7 +445,7 @@ class TransientExceptionTesst(_fixtures.FixtureTest): ne_(u1.id, None) eq_(sess.query(User).count(), 2) -class ReversePKsTest(_base.MappedTest): +class ReversePKsTest(fixtures.MappedTest): """reverse the primary keys of two entities and ensure bookkeeping succeeds.""" @@ -503,7 +504,7 @@ class ReversePKsTest(_base.MappedTest): assert session.query(User).get([1, EDITABLE]) is a_editable -class SelfReferentialTest(_base.MappedTest): +class SelfReferentialTest(fixtures.MappedTest): # mssql, mysql don't allow # ON UPDATE on self-referential keys __unsupported_on__ = ('mssql','mysql') @@ -613,7 +614,7 @@ class SelfReferentialTest(_base.MappedTest): Node.name.in_(['n11', 'n12', 'n13']))]) -class NonPKCascadeTest(_base.MappedTest): +class NonPKCascadeTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): if testing.against('oracle'): @@ -719,7 +720,7 @@ class NonPKCascadeTest(_base.MappedTest): eq_(User(username='fred', fullname='jack'), u1) -class CascadeToFKPKTest(_base.MappedTest, testing.AssertsCompiledSQL): +class CascadeToFKPKTest(fixtures.MappedTest, testing.AssertsCompiledSQL): """A primary key mutation cascades onto a foreign key that is itself a primary key.""" @@ -972,7 +973,7 @@ class CascadeToFKPKTest(_base.MappedTest, testing.AssertsCompiledSQL): [('jack',), ('jack', )]) -class JoinedInheritanceTest(_base.MappedTest): +class JoinedInheritanceTest(fixtures.MappedTest): """Test cascades of pk->pk/fk on joined table inh.""" # mssql doesn't allow ON UPDATE on self-referential keys diff --git a/test/orm/test_onetoone.py b/test/orm/test_onetoone.py index fab99d93c6..09dc379b89 100644 --- a/test/orm/test_onetoone.py +++ b/test/orm/test_onetoone.py @@ -3,10 +3,10 @@ from test.lib import testing from sqlalchemy import Integer, String, ForeignKey from test.lib.schema import Table, Column from sqlalchemy.orm import mapper, relationship, create_session -from test.orm import _base +from test.lib import fixtures -class O2OTest(_base.MappedTest): +class O2OTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('jack', metadata, diff --git a/test/orm/test_pickled.py b/test/orm/test_pickled.py index 3291d2ff9f..861ae7e6fc 100644 --- a/test/orm/test_pickled.py +++ b/test/orm/test_pickled.py @@ -11,11 +11,12 @@ from sqlalchemy.orm import mapper, relationship, create_session, \ clear_mappers, exc as orm_exc,\ configure_mappers, Session, lazyload_all,\ lazyload, aliased -from test.orm import _base, _fixtures +from test.lib import fixtures +from test.orm import _fixtures from test.lib.pickleable import User, Address, Order, Child1, Child2, Parent, Screen, EmailUser -class PickleTest(_base.MappedTest): +class PickleTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('users', metadata, @@ -318,7 +319,7 @@ class PickleTest(_base.MappedTest): screen2 = Screen(Child2(), screen1) pickle.loads(pickle.dumps(screen2)) -class PolymorphicDeferredTest(_base.MappedTest): +class PolymorphicDeferredTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('users', metadata, @@ -421,7 +422,7 @@ class TupleLabelTest(_fixtures.FixtureTest): ret = sess.query(User, Address).join(User.addresses).all() pickle.loads(pickle.dumps(ret, pickled)) -class CustomSetupTeardownTest(_base.MappedTest): +class CustomSetupTeardownTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('users', metadata, diff --git a/test/orm/test_query.py b/test/orm/test_query.py index e5f002960e..b422110824 100644 --- a/test/orm/test_query.py +++ b/test/orm/test_query.py @@ -14,7 +14,7 @@ from test.lib import testing, AssertsCompiledSQL, Column, engines from test.orm import _fixtures -from test.orm import _base +from test.lib import fixtures from sqlalchemy.orm.util import join, outerjoin, with_parent @@ -197,7 +197,7 @@ class GetTest(QueryTest): s = users.outerjoin(addresses) - class UserThing(_base.ComparableEntity): + class UserThing(fixtures.ComparableEntity): pass mapper(UserThing, s, properties={ @@ -1779,7 +1779,7 @@ class ImmediateTest(_fixtures.FixtureTest): sess.bind = testing.db eq_(sess.query().value(sa.literal_column('1').label('x')), 1) -class UpdateDeleteTest(_base.MappedTest): +class UpdateDeleteTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('users', metadata, @@ -1965,7 +1965,7 @@ class UpdateDeleteTest(_base.MappedTest): Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('counter', Integer, nullable=False, default=0) ) - class Data(_base.ComparableEntity): + class Data(fixtures.ComparableEntity): pass mapper(Data, data, properties={'cnt':data.c.counter}) diff --git a/test/orm/test_relationships.py b/test/orm/test_relationships.py index c671c19bc0..7f2030959f 100644 --- a/test/orm/test_relationships.py +++ b/test/orm/test_relationships.py @@ -9,10 +9,11 @@ from sqlalchemy.orm import mapper, relationship, relation, \ clear_mappers, sessionmaker, attributes,\ Session, composite, column_property from test.lib.testing import eq_, startswith_ -from test.orm import _base, _fixtures +from test.lib import fixtures +from test.orm import _fixtures -class DependencyTwoParentTest(_base.MappedTest): +class DependencyTwoParentTest(fixtures.MappedTest): """Test flush() when a mapper is dependent on multiple relationships""" run_setup_mappers = 'once' @@ -113,7 +114,7 @@ class DependencyTwoParentTest(_base.MappedTest): session.flush() -class CompositeSelfRefFKTest(_base.MappedTest): +class CompositeSelfRefFKTest(fixtures.MappedTest): """Tests a composite FK where, in the relationship(), one col points to itself in the same table. @@ -276,7 +277,7 @@ class CompositeSelfRefFKTest(_base.MappedTest): assert sess.query(Employee).\ get([c2.company_id, 3]).reports_to.name == 'emp5' -class ComplexPostUpdateTest(_base.MappedTest): +class ComplexPostUpdateTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table("jobs", metadata, @@ -424,7 +425,7 @@ class ComplexPostUpdateTest(_base.MappedTest): s.delete(j) s.flush() -class FKsAsPksTest(_base.MappedTest): +class FKsAsPksTest(fixtures.MappedTest): """Syncrules on foreign keys that are also primary""" @classmethod @@ -535,7 +536,7 @@ class FKsAsPksTest(_base.MappedTest): primary_key=True, autoincrement=False, nullable=True)) tableC.create() - class C(_base.BasicEntity): + class C(fixtures.BasicEntity): pass mapper(C, tableC, properties={ 'a':relationship(A, cascade="save-update") @@ -659,7 +660,7 @@ class FKsAsPksTest(_base.MappedTest): assert a1 not in sess assert b1 not in sess -class UniqueColReferenceSwitchTest(_base.MappedTest): +class UniqueColReferenceSwitchTest(fixtures.MappedTest): """test a relationship based on a primary join against a unique non-pk column""" @@ -711,7 +712,7 @@ class UniqueColReferenceSwitchTest(_base.MappedTest): session.delete(a1) session.flush() -class RelationshipToSelectableTest(_base.MappedTest): +class RelationshipToSelectableTest(fixtures.MappedTest): """Test a map to a select that relates to a map to the table.""" @classmethod @@ -729,9 +730,9 @@ class RelationshipToSelectableTest(_base.MappedTest): def test_basic(self): items = self.tables.items - class Container(_base.BasicEntity): + class Container(fixtures.BasicEntity): pass - class LineItem(_base.BasicEntity): + class LineItem(fixtures.BasicEntity): pass container_select = sa.select( @@ -778,7 +779,7 @@ class RelationshipToSelectableTest(_base.MappedTest): for old, new in zip(con.lineItems, newcon.lineItems): eq_(old.id, new.id) -class FKEquatedToConstantTest(_base.MappedTest): +class FKEquatedToConstantTest(fixtures.MappedTest): """test a relationship with a non-column entity in the primary join, is not viewonly, and also has the non-column's clause mentioned in the foreign keys list. @@ -802,9 +803,9 @@ class FKEquatedToConstantTest(_base.MappedTest): def test_basic(self): tag_foo, tags = self.tables.tag_foo, self.tables.tags - class Tag(_base.ComparableEntity): + class Tag(fixtures.ComparableEntity): pass - class TagInstance(_base.ComparableEntity): + class TagInstance(fixtures.ComparableEntity): pass mapper(Tag, tags, properties={ @@ -837,7 +838,7 @@ class FKEquatedToConstantTest(_base.MappedTest): [TagInstance(data='iplc_case'), TagInstance(data='not_iplc_case')] ) -class BackrefPropagatesForwardsArgs(_base.MappedTest): +class BackrefPropagatesForwardsArgs(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -883,7 +884,7 @@ class BackrefPropagatesForwardsArgs(_base.MappedTest): Address(email='a1', user=User(name='u1')) ]) -class AmbiguousJoinInterpretedAsSelfRef(_base.MappedTest): +class AmbiguousJoinInterpretedAsSelfRef(fixtures.MappedTest): """test ambiguous joins due to FKs on both sides treated as self-referential. @@ -1038,7 +1039,7 @@ class ManualBackrefTest(_fixtures.FixtureTest): "reference mapper Mapper\|User\|users", configure_mappers) -class JoinConditionErrorTest(testing.TestBase): +class JoinConditionErrorTest(fixtures.TestBase): def test_clauseelement_pj(self): from sqlalchemy.ext.declarative import declarative_base @@ -1171,7 +1172,7 @@ class JoinConditionErrorTest(testing.TestBase): def teardown(self): clear_mappers() -class TypeMatchTest(_base.MappedTest): +class TypeMatchTest(fixtures.MappedTest): """test errors raised when trying to add items whose type is not handled by a relationship""" @@ -1202,9 +1203,9 @@ class TypeMatchTest(_base.MappedTest): self.tables.c, self.tables.b) - class A(_base.BasicEntity): pass - class B(_base.BasicEntity): pass - class C(_base.BasicEntity): pass + class A(fixtures.BasicEntity): pass + class B(fixtures.BasicEntity): pass + class C(fixtures.BasicEntity): pass mapper(A, a, properties={'bs':relationship(B)}) mapper(B, b) mapper(C, c) @@ -1228,9 +1229,9 @@ class TypeMatchTest(_base.MappedTest): self.tables.c, self.tables.b) - class A(_base.BasicEntity): pass - class B(_base.BasicEntity): pass - class C(_base.BasicEntity): pass + class A(fixtures.BasicEntity): pass + class B(fixtures.BasicEntity): pass + class C(fixtures.BasicEntity): pass mapper(A, a, properties={'bs':relationship(B, cascade="none")}) mapper(B, b) mapper(C, c) @@ -1253,8 +1254,8 @@ class TypeMatchTest(_base.MappedTest): self.tables.c, self.tables.b) - class A(_base.BasicEntity): pass - class B(_base.BasicEntity): pass + class A(fixtures.BasicEntity): pass + class B(fixtures.BasicEntity): pass class C(B): pass mapper(A, a, properties={'bs':relationship(B, cascade="none")}) mapper(B, b) @@ -1278,9 +1279,9 @@ class TypeMatchTest(_base.MappedTest): self.tables.b, self.tables.d) - class A(_base.BasicEntity): pass + class A(fixtures.BasicEntity): pass class B(A): pass - class D(_base.BasicEntity): pass + class D(fixtures.BasicEntity): pass mapper(A, a) mapper(B, b, inherits=A) mapper(D, d, properties={"a":relationship(A, cascade="none")}) @@ -1299,9 +1300,9 @@ class TypeMatchTest(_base.MappedTest): self.tables.b, self.tables.d) - class A(_base.BasicEntity): pass - class B(_base.BasicEntity): pass - class D(_base.BasicEntity): pass + class A(fixtures.BasicEntity): pass + class B(fixtures.BasicEntity): pass + class D(fixtures.BasicEntity): pass mapper(A, a) mapper(B, b) mapper(D, d, properties={"a":relationship(A)}) @@ -1313,7 +1314,7 @@ class TypeMatchTest(_base.MappedTest): "doesn't handle objects of type", sess.add, d1) -class TypedAssociationTable(_base.MappedTest): +class TypedAssociationTable(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -1341,8 +1342,8 @@ class TypedAssociationTable(_base.MappedTest): """Many-to-many tables with special types for candidate keys.""" - class T1(_base.BasicEntity): pass - class T2(_base.BasicEntity): pass + class T1(fixtures.BasicEntity): pass + class T2(fixtures.BasicEntity): pass mapper(T2, t2) mapper(T1, t1, properties={ 't2s':relationship(T2, secondary=t3, backref='t1s')}) @@ -1366,7 +1367,7 @@ class TypedAssociationTable(_base.MappedTest): assert t3.count().scalar() == 1 -class ViewOnlyM2MBackrefTest(_base.MappedTest): +class ViewOnlyM2MBackrefTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table("t1", metadata, @@ -1388,8 +1389,8 @@ class ViewOnlyM2MBackrefTest(_base.MappedTest): self.tables.t2, self.tables.t1) - class A(_base.ComparableEntity):pass - class B(_base.ComparableEntity):pass + class A(fixtures.ComparableEntity):pass + class B(fixtures.ComparableEntity):pass mapper(A, t1, properties={ 'bs':relationship(B, secondary=t1t2, @@ -1410,7 +1411,7 @@ class ViewOnlyM2MBackrefTest(_base.MappedTest): sess.query(B).first(), B(as_=[A(id=a1.id)]) ) -class ViewOnlyOverlappingNames(_base.MappedTest): +class ViewOnlyOverlappingNames(fixtures.MappedTest): """'viewonly' mappings with overlapping PK column names.""" @classmethod @@ -1442,9 +1443,9 @@ class ViewOnlyOverlappingNames(_base.MappedTest): error. """ - class C1(_base.BasicEntity): pass - class C2(_base.BasicEntity): pass - class C3(_base.BasicEntity): pass + class C1(fixtures.BasicEntity): pass + class C2(fixtures.BasicEntity): pass + class C3(fixtures.BasicEntity): pass mapper(C1, t1, properties={ 't2s':relationship(C2), @@ -1476,7 +1477,7 @@ class ViewOnlyOverlappingNames(_base.MappedTest): assert set([x.id for x in c1.t2s]) == set([c2a.id, c2b.id]) assert set([x.id for x in c1.t2_view]) == set([c2b.id]) -class ViewOnlyUniqueNames(_base.MappedTest): +class ViewOnlyUniqueNames(fixtures.MappedTest): """'viewonly' mappings with unique PK column names.""" @classmethod @@ -1507,9 +1508,9 @@ class ViewOnlyUniqueNames(_base.MappedTest): PK column names and should not produce 'mapper has no columnX' error. """ - class C1(_base.BasicEntity): pass - class C2(_base.BasicEntity): pass - class C3(_base.BasicEntity): pass + class C1(fixtures.BasicEntity): pass + class C2(fixtures.BasicEntity): pass + class C3(fixtures.BasicEntity): pass mapper(C1, t1, properties={ 't2s':relationship(C2), @@ -1541,7 +1542,7 @@ class ViewOnlyUniqueNames(_base.MappedTest): assert set([x.t2id for x in c1.t2s]) == set([c2a.t2id, c2b.t2id]) assert set([x.t2id for x in c1.t2_view]) == set([c2b.t2id]) -class ViewOnlyLocalRemoteM2M(testing.TestBase): +class ViewOnlyLocalRemoteM2M(fixtures.TestBase): """test that local-remote is correctly determined for m2m""" def test_local_remote(self): @@ -1573,7 +1574,7 @@ class ViewOnlyLocalRemoteM2M(testing.TestBase): -class ViewOnlyNonEquijoin(_base.MappedTest): +class ViewOnlyNonEquijoin(fixtures.MappedTest): """'viewonly' mappings based on non-equijoins.""" @classmethod @@ -1587,9 +1588,9 @@ class ViewOnlyNonEquijoin(_base.MappedTest): def test_viewonly_join(self): bars, foos = self.tables.bars, self.tables.foos - class Foo(_base.ComparableEntity): + class Foo(fixtures.ComparableEntity): pass - class Bar(_base.ComparableEntity): + class Bar(fixtures.ComparableEntity): pass mapper(Foo, foos, properties={ @@ -1616,7 +1617,7 @@ class ViewOnlyNonEquijoin(_base.MappedTest): Foo(id=9, bars=[Bar(fid=2), Bar(fid=3), Bar(fid=6), Bar(fid=7)])) -class ViewOnlyRepeatedRemoteColumn(_base.MappedTest): +class ViewOnlyRepeatedRemoteColumn(fixtures.MappedTest): """'viewonly' mappings that contain the same 'remote' column twice""" @classmethod @@ -1633,9 +1634,9 @@ class ViewOnlyRepeatedRemoteColumn(_base.MappedTest): def test_relationship_on_or(self): bars, foos = self.tables.bars, self.tables.foos - class Foo(_base.ComparableEntity): + class Foo(fixtures.ComparableEntity): pass - class Bar(_base.ComparableEntity): + class Bar(fixtures.ComparableEntity): pass mapper(Foo, foos, properties={ @@ -1665,7 +1666,7 @@ class ViewOnlyRepeatedRemoteColumn(_base.MappedTest): eq_(sess.query(Foo).filter_by(id=f2.id).one(), Foo(bars=[Bar(data='b3')])) -class ViewOnlyRepeatedLocalColumn(_base.MappedTest): +class ViewOnlyRepeatedLocalColumn(fixtures.MappedTest): """'viewonly' mappings that contain the same 'local' column twice""" @classmethod @@ -1684,9 +1685,9 @@ class ViewOnlyRepeatedLocalColumn(_base.MappedTest): def test_relationship_on_or(self): bars, foos = self.tables.bars, self.tables.foos - class Foo(_base.ComparableEntity): + class Foo(fixtures.ComparableEntity): pass - class Bar(_base.ComparableEntity): + class Bar(fixtures.ComparableEntity): pass mapper(Foo, foos, properties={ @@ -1716,7 +1717,7 @@ class ViewOnlyRepeatedLocalColumn(_base.MappedTest): eq_(sess.query(Foo).filter_by(id=f2.id).one(), Foo(bars=[Bar(data='b3'), Bar(data='b4')])) -class ViewOnlyComplexJoin(_base.MappedTest): +class ViewOnlyComplexJoin(fixtures.MappedTest): """'viewonly' mappings with a complex join condition.""" @classmethod @@ -1805,7 +1806,7 @@ class ViewOnlyComplexJoin(_base.MappedTest): sa.orm.configure_mappers) -class ExplicitLocalRemoteTest(_base.MappedTest): +class ExplicitLocalRemoteTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -1967,7 +1968,7 @@ class ExplicitLocalRemoteTest(_base.MappedTest): mapper(T2, t2) assert_raises(sa.exc.ArgumentError, sa.orm.configure_mappers) -class InvalidRemoteSideTest(_base.MappedTest): +class InvalidRemoteSideTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('t1', metadata, @@ -2040,7 +2041,7 @@ class InvalidRemoteSideTest(_base.MappedTest): configure_mappers) -class InvalidRelationshipEscalationTest(_base.MappedTest): +class InvalidRelationshipEscalationTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -2403,7 +2404,7 @@ class InvalidRelationshipEscalationTest(_base.MappedTest): configure_mappers) -class InvalidRelationshipEscalationTestM2M(_base.MappedTest): +class InvalidRelationshipEscalationTestM2M(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -2731,7 +2732,7 @@ class ActiveHistoryFlagTest(_fixtures.FixtureTest): -class RelationDeprecationTest(_base.MappedTest): +class RelationDeprecationTest(fixtures.MappedTest): """test usage of the old 'relation' function.""" run_inserts = 'once' diff --git a/test/orm/test_scoping.py b/test/orm/test_scoping.py index c7e1b566c2..527df89371 100644 --- a/test/orm/test_scoping.py +++ b/test/orm/test_scoping.py @@ -6,17 +6,17 @@ from sqlalchemy import Integer, String, ForeignKey from test.lib.schema import Table, Column from sqlalchemy.orm import mapper, relationship, query from test.lib.testing import eq_ -from test.orm import _base +from test.lib import fixtures -class _ScopedTest(_base.MappedTest): +class _ScopedTest(fixtures.MappedTest): """Adds another lookup bucket to emulate Session globals.""" run_setup_mappers = 'once' _artifact_registries = ( - _base.MappedTest._artifact_registries + ('scoping',)) + fixtures.MappedTest._artifact_registries + ('scoping',)) @classmethod def setup_class(cls): @@ -29,7 +29,7 @@ class _ScopedTest(_base.MappedTest): super(_ScopedTest, cls).teardown_class() -class ScopedSessionTest(_base.MappedTest): +class ScopedSessionTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -48,9 +48,9 @@ class ScopedSessionTest(_base.MappedTest): class CustomQuery(query.Query): pass - class SomeObject(_base.ComparableEntity): + class SomeObject(fixtures.ComparableEntity): query = Session.query_property() - class SomeOtherObject(_base.ComparableEntity): + class SomeOtherObject(fixtures.ComparableEntity): query = Session.query_property() custom_query = Session.query_property(query_cls=CustomQuery) diff --git a/test/orm/test_selectable.py b/test/orm/test_selectable.py index 8eb7e38c1e..7e4a92de19 100644 --- a/test/orm/test_selectable.py +++ b/test/orm/test_selectable.py @@ -6,13 +6,13 @@ from sqlalchemy import String, Integer, select from test.lib.schema import Table, Column from sqlalchemy.orm import mapper, Session from test.lib.testing import eq_, AssertsCompiledSQL -from test.orm import _base +from test.lib import fixtures # TODO: more tests mapping to selects -class SelectableNoFromsTest(_base.MappedTest, AssertsCompiledSQL): +class SelectableNoFromsTest(fixtures.MappedTest, AssertsCompiledSQL): @classmethod def define_tables(cls, metadata): Table('common', metadata, diff --git a/test/orm/test_session.py b/test/orm/test_session.py index 7e13ed7e5e..12b394c033 100644 --- a/test/orm/test_session.py +++ b/test/orm/test_session.py @@ -13,8 +13,9 @@ from test.lib.schema import Table, Column from sqlalchemy.orm import mapper, relationship, backref, joinedload, \ exc as orm_exc, object_session from sqlalchemy.util import pypy -from test.engine import _base as engine_base -from test.orm import _base, _fixtures +from test.lib import fixtures +from test.lib import fixtures +from test.orm import _fixtures class SessionTest(_fixtures.FixtureTest): run_inserts = None @@ -1319,7 +1320,7 @@ class SessionDataTest(_fixtures.FixtureTest): assert newad.email_address == 'a new address' -class DisposedStates(_base.MappedTest): +class DisposedStates(fixtures.MappedTest): run_setup_mappers = 'once' run_inserts = 'once' run_deletes = None @@ -1405,7 +1406,7 @@ class DisposedStates(_base.MappedTest): sess.rollback() -class SessionInterface(testing.TestBase): +class SessionInterface(fixtures.TestBase): """Bogus args to Session methods produce actionable exceptions.""" # TODO: expand with message body assertions. @@ -1537,7 +1538,7 @@ class SessionInterface(testing.TestBase): self._test_class_guards(early) -class TLTransactionTest(_base.MappedTest): +class TLTransactionTest(fixtures.MappedTest): run_dispose_bind = 'once' @classmethod diff --git a/test/orm/test_subquery_relations.py b/test/orm/test_subquery_relations.py index ff20496e44..dc2557674c 100644 --- a/test/orm/test_subquery_relations.py +++ b/test/orm/test_subquery_relations.py @@ -8,7 +8,8 @@ from sqlalchemy.orm import backref, subqueryload, subqueryload_all, \ from test.lib.testing import eq_, assert_raises, \ assert_raises_message from test.lib.assertsql import CompiledSQL -from test.orm import _base, _fixtures +from test.lib import fixtures +from test.orm import _fixtures import sqlalchemy as sa class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL): @@ -758,7 +759,7 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL): assert_raises(sa.exc.SAWarning, s.query(User).options(subqueryload(User.order)).all) -class OrderBySecondaryTest(_base.MappedTest): +class OrderBySecondaryTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('m2m', metadata, @@ -799,8 +800,8 @@ class OrderBySecondaryTest(_base.MappedTest): self.tables.m2m, self.tables.b) - class A(_base.ComparableEntity):pass - class B(_base.ComparableEntity):pass + class A(fixtures.ComparableEntity):pass + class B(fixtures.ComparableEntity):pass mapper(A, a, properties={ 'bs':relationship(B, secondary=m2m, lazy='subquery', order_by=m2m.c.id) @@ -815,7 +816,7 @@ class OrderBySecondaryTest(_base.MappedTest): ]) self.assert_sql_count(testing.db, go, 2) -class SelfReferentialTest(_base.MappedTest): +class SelfReferentialTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('nodes', metadata, @@ -827,7 +828,7 @@ class SelfReferentialTest(_base.MappedTest): def test_basic(self): nodes = self.tables.nodes - class Node(_base.ComparableEntity): + class Node(fixtures.ComparableEntity): def append(self, node): self.children.append(node) @@ -879,7 +880,7 @@ class SelfReferentialTest(_base.MappedTest): def test_lazy_fallback_doesnt_affect_eager(self): nodes = self.tables.nodes - class Node(_base.ComparableEntity): + class Node(fixtures.ComparableEntity): def append(self, node): self.children.append(node) @@ -913,7 +914,7 @@ class SelfReferentialTest(_base.MappedTest): def test_with_deferred(self): nodes = self.tables.nodes - class Node(_base.ComparableEntity): + class Node(fixtures.ComparableEntity): def append(self, node): self.children.append(node) @@ -956,7 +957,7 @@ class SelfReferentialTest(_base.MappedTest): def test_options(self): nodes = self.tables.nodes - class Node(_base.ComparableEntity): + class Node(fixtures.ComparableEntity): def append(self, node): self.children.append(node) @@ -993,7 +994,7 @@ class SelfReferentialTest(_base.MappedTest): nodes = self.tables.nodes """no join depth is set, so no eager loading occurs.""" - class Node(_base.ComparableEntity): + class Node(fixtures.ComparableEntity): def append(self, node): self.children.append(node) diff --git a/test/orm/test_transaction.py b/test/orm/test_transaction.py index cfbfc971aa..839585f4eb 100644 --- a/test/orm/test_transaction.py +++ b/test/orm/test_transaction.py @@ -7,7 +7,7 @@ from sqlalchemy.orm import exc as orm_exc from sqlalchemy.orm import * from test.lib.util import gc_collect from test.lib import testing -from test.orm import _base +from test.lib import fixtures from test.orm._fixtures import FixtureTest class TransactionTest(FixtureTest): @@ -608,7 +608,7 @@ class AutoCommitTest(TransactionTest): assert 'id' not in u1.__dict__ eq_(u1.id, 3) -class NaturalPKRollbackTest(_base.MappedTest): +class NaturalPKRollbackTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('users', metadata, diff --git a/test/orm/test_unitofwork.py b/test/orm/test_unitofwork.py index fc5f6c7250..5716018037 100644 --- a/test/orm/test_unitofwork.py +++ b/test/orm/test_unitofwork.py @@ -15,8 +15,9 @@ from sqlalchemy.orm import mapper, relationship, create_session, \ column_property, attributes, Session, reconstructor, object_session from test.lib.testing import eq_, ne_ from test.lib.util import gc_collect -from test.orm import _base, _fixtures -from test.engine import _base as engine_base +from test.lib import fixtures +from test.orm import _fixtures +from test.lib import fixtures from test.lib.assertsql import AllOf, CompiledSQL import gc @@ -58,7 +59,7 @@ class HistoryTest(_fixtures.FixtureTest): assert u.addresses[0].user == u session.close() -class UnicodeTest(_base.MappedTest): +class UnicodeTest(fixtures.MappedTest): __requires__ = ('unicode_connections',) @classmethod @@ -123,7 +124,7 @@ class UnicodeTest(_base.MappedTest): t1 = session.query(Test).filter_by(id=t1.id).one() assert len(t1.t2s) == 2 -class UnicodeSchemaTest(_base.MappedTest): +class UnicodeSchemaTest(fixtures.MappedTest): __requires__ = ('unicode_connections', 'unicode_ddl',) run_dispose_bind = 'once' @@ -164,9 +165,9 @@ class UnicodeSchemaTest(_base.MappedTest): def test_mapping(self): t2, t1 = self.tables.t2, self.tables.t1 - class A(_base.ComparableEntity): + class A(fixtures.ComparableEntity): pass - class B(_base.ComparableEntity): + class B(fixtures.ComparableEntity): pass mapper(A, t1, properties={ @@ -203,7 +204,7 @@ class UnicodeSchemaTest(_base.MappedTest): def test_inheritance_mapping(self): t2, t1 = self.tables.t2, self.tables.t1 - class A(_base.ComparableEntity): + class A(fixtures.ComparableEntity): pass class B(A): pass @@ -224,7 +225,7 @@ class UnicodeSchemaTest(_base.MappedTest): eq_([A(b=5), B(e=7)], session.query(A).all()) -class BinaryHistTest(_base.MappedTest, testing.AssertsExecutionResults): +class BinaryHistTest(fixtures.MappedTest, testing.AssertsExecutionResults): @classmethod def define_tables(cls, metadata): Table('t1', metadata, @@ -270,7 +271,7 @@ class BinaryHistTest(_base.MappedTest, testing.AssertsExecutionResults): -class PKTest(_base.MappedTest): +class PKTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -342,7 +343,7 @@ class PKTest(_base.MappedTest): session.flush() -class ForeignPKTest(_base.MappedTest): +class ForeignPKTest(fixtures.MappedTest): """Detection of the relationship direction on PK joins.""" @classmethod @@ -391,7 +392,7 @@ class ForeignPKTest(_base.MappedTest): eq_(peoplesites.count(peoplesites.c.person=='im the key').scalar(), 1) -class ClauseAttributesTest(_base.MappedTest): +class ClauseAttributesTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -465,7 +466,7 @@ class ClauseAttributesTest(_base.MappedTest): assert (u.counter == 5) is True -class PassiveDeletesTest(_base.MappedTest): +class PassiveDeletesTest(fixtures.MappedTest): __requires__ = ('foreign_keys',) @classmethod @@ -569,7 +570,7 @@ class PassiveDeletesTest(_base.MappedTest): mapper(MyClass, mytable) assert_raises(sa.exc.SAWarning, sa.orm.configure_mappers) -class ExtraPassiveDeletesTest(_base.MappedTest): +class ExtraPassiveDeletesTest(fixtures.MappedTest): __requires__ = ('foreign_keys',) @classmethod @@ -683,7 +684,7 @@ class ExtraPassiveDeletesTest(_base.MappedTest): # no load for "children" should occur self.assert_sql_count(testing.db, session.flush, 1) -class ColumnCollisionTest(_base.MappedTest): +class ColumnCollisionTest(fixtures.MappedTest): """Ensure the mapper doesn't break bind param naming rules on flush.""" @classmethod @@ -697,7 +698,7 @@ class ColumnCollisionTest(_base.MappedTest): def test_naming(self): book = self.tables.book - class Book(_base.ComparableEntity): + class Book(fixtures.ComparableEntity): pass mapper(Book, book) @@ -717,7 +718,7 @@ class ColumnCollisionTest(_base.MappedTest): -class DefaultTest(_base.MappedTest): +class DefaultTest(fixtures.MappedTest): """Exercise mappings on columns with DefaultGenerators. Tests that when saving objects whose table contains DefaultGenerators, @@ -914,7 +915,7 @@ class DefaultTest(_base.MappedTest): Secondary(data='s1'), Secondary(data='s2')])) -class ColumnPropertyTest(_base.MappedTest): +class ColumnPropertyTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('data', metadata, @@ -1284,7 +1285,7 @@ class SaveTest(_fixtures.FixtureTest): def test_synonym(self): users = self.tables.users - class SUser(_base.BasicEntity): + class SUser(fixtures.BasicEntity): def _get_name(self): return "User:" + self.name def _set_name(self, name): @@ -1938,7 +1939,7 @@ class ManyToManyTest(_fixtures.FixtureTest): """Basic test of an association object""" - class IKAssociation(_base.ComparableEntity): + class IKAssociation(fixtures.ComparableEntity): pass mapper(Keyword, keywords) @@ -2023,7 +2024,7 @@ class SaveTest2(_fixtures.FixtureTest): {'user_id': 2, 'email_address': 'a2'}), ) -class SaveTest3(_base.MappedTest): +class SaveTest3(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('items', metadata, @@ -2077,7 +2078,7 @@ class SaveTest3(_base.MappedTest): session.flush() assert assoc.count().scalar() == 0 -class BooleanColTest(_base.MappedTest): +class BooleanColTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('t1_t', metadata, @@ -2089,7 +2090,7 @@ class BooleanColTest(_base.MappedTest): t1_t = self.tables.t1_t # use the regular mapper - class T(_base.ComparableEntity): + class T(fixtures.ComparableEntity): pass orm_mapper(T, t1_t, order_by=t1_t.c.id) @@ -2120,7 +2121,7 @@ class BooleanColTest(_base.MappedTest): sess.flush() eq_(sess.query(T).filter(T.value==True).all(), [T(value=True, name="t1"),T(value=True, name="t3")]) -class DontAllowFlushOnLoadingObjectTest(_base.MappedTest): +class DontAllowFlushOnLoadingObjectTest(fixtures.MappedTest): """Test that objects with NULL identity keys aren't permitted to complete a flush. User-defined callables that execute during a load may modify state @@ -2141,7 +2142,7 @@ class DontAllowFlushOnLoadingObjectTest(_base.MappedTest): def test_flush_raises(self): t1 = self.tables.t1 - class T1(_base.ComparableEntity): + class T1(fixtures.ComparableEntity): @reconstructor def go(self): # blow away 'id', no change event. @@ -2183,7 +2184,7 @@ class DontAllowFlushOnLoadingObjectTest(_base.MappedTest): -class RowSwitchTest(_base.MappedTest): +class RowSwitchTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): # parent @@ -2337,7 +2338,7 @@ class RowSwitchTest(_base.MappedTest): assert list(sess.execute(t5.select(), mapper=T5)) == [(2, 'some other t5')] assert list(sess.execute(t6.select(), mapper=T5)) == [(1, 'some other t6', 2)] -class InheritingRowSwitchTest(_base.MappedTest): +class InheritingRowSwitchTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('parent', metadata, @@ -2394,7 +2395,7 @@ class InheritingRowSwitchTest(_base.MappedTest): -class TransactionTest(_base.MappedTest): +class TransactionTest(fixtures.MappedTest): __requires__ = ('deferrable_constraints',) __whitelist__ = ('sqlite',) diff --git a/test/orm/test_unitofworkv2.py b/test/orm/test_unitofworkv2.py index dc818a8a61..50bc2cbaea 100644 --- a/test/orm/test_unitofworkv2.py +++ b/test/orm/test_unitofworkv2.py @@ -1,8 +1,9 @@ from test.lib.testing import eq_, assert_raises, assert_raises_message from test.lib import testing from test.lib.schema import Table, Column +from test.orm import _fixtures +from test.lib import fixtures from sqlalchemy import Integer, String, ForeignKey, func -from test.orm import _fixtures, _base from sqlalchemy.orm import mapper, relationship, backref, \ create_session, unitofwork, attributes,\ Session @@ -979,7 +980,7 @@ class SingleCycleTest(UOWTest): -class SingleCyclePlusAttributeTest(_base.MappedTest, +class SingleCyclePlusAttributeTest(fixtures.MappedTest, testing.AssertsExecutionResults, AssertsUOW): @classmethod def define_tables(cls, metadata): @@ -999,9 +1000,9 @@ class SingleCyclePlusAttributeTest(_base.MappedTest, def test_flush_size(self): foobars, nodes = self.tables.foobars, self.tables.nodes - class Node(_base.ComparableEntity): + class Node(fixtures.ComparableEntity): pass - class FooBar(_base.ComparableEntity): + class FooBar(fixtures.ComparableEntity): pass mapper(Node, nodes, properties={ @@ -1026,7 +1027,7 @@ class SingleCyclePlusAttributeTest(_base.MappedTest, sess.flush() -class SingleCycleM2MTest(_base.MappedTest, +class SingleCycleM2MTest(fixtures.MappedTest, testing.AssertsExecutionResults, AssertsUOW): @classmethod @@ -1049,7 +1050,7 @@ class SingleCycleM2MTest(_base.MappedTest, def test_many_to_many_one(self): nodes, node_to_nodes = self.tables.nodes, self.tables.node_to_nodes - class Node(_base.ComparableEntity): + class Node(fixtures.ComparableEntity): pass mapper(Node, nodes, properties={ @@ -1158,7 +1159,7 @@ class SingleCycleM2MTest(_base.MappedTest, ), ) -class RowswitchAccountingTest(_base.MappedTest): +class RowswitchAccountingTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('parent', metadata, @@ -1211,7 +1212,7 @@ class RowswitchAccountingTest(_base.MappedTest): sess.flush() -class BatchInsertsTest(_base.MappedTest, testing.AssertsExecutionResults): +class BatchInsertsTest(fixtures.MappedTest, testing.AssertsExecutionResults): @classmethod def define_tables(cls, metadata): Table('t', metadata, @@ -1228,7 +1229,7 @@ class BatchInsertsTest(_base.MappedTest, testing.AssertsExecutionResults): key present statements together. """ - class T(_base.ComparableEntity): + class T(fixtures.ComparableEntity): pass mapper(T, t) sess = Session() diff --git a/test/orm/test_utils.py b/test/orm/test_utils.py index 9664d0c232..29aa8ec778 100644 --- a/test/orm/test_utils.py +++ b/test/orm/test_utils.py @@ -6,15 +6,13 @@ from sqlalchemy import MetaData from sqlalchemy import Table from sqlalchemy.orm import aliased from sqlalchemy.orm import mapper, create_session - - -from test.lib import TestBase, testing - +from test.lib import testing +from test.lib import fixtures from test.orm import _fixtures from test.lib.testing import eq_ -class AliasedClassTest(TestBase): +class AliasedClassTest(fixtures.TestBase): def point_map(self, cls): table = Table('point', MetaData(), Column('id', Integer(), primary_key=True), diff --git a/test/orm/test_versioning.py b/test/orm/test_versioning.py index 74e342e0e6..08b112fcce 100644 --- a/test/orm/test_versioning.py +++ b/test/orm/test_versioning.py @@ -7,8 +7,9 @@ from sqlalchemy.orm import mapper, relationship, Session, \ create_session, column_property, sessionmaker,\ exc as orm_exc from test.lib.testing import eq_, ne_, assert_raises, assert_raises_message -from test.orm import _base, _fixtures -from test.engine import _base as engine_base +from test.lib import fixtures +from test.orm import _fixtures +from test.lib import fixtures _uuids = [ @@ -32,7 +33,7 @@ def make_uuid(): """generate uuids even on Python 2.4 which has no 'uuid'""" return _uuids.pop(0) -class VersioningTest(_base.MappedTest): +class VersioningTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): @@ -44,7 +45,7 @@ class VersioningTest(_base.MappedTest): @classmethod def setup_classes(cls): - class Foo(cls.Comparable): + class Foo(cls.Basic): pass def _fixture(self): @@ -314,7 +315,7 @@ class VersioningTest(_base.MappedTest): s1.merge, f2 ) -class RowSwitchTest(_base.MappedTest): +class RowSwitchTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('p', metadata, @@ -330,9 +331,9 @@ class RowSwitchTest(_base.MappedTest): @classmethod def setup_classes(cls): - class P(cls.Comparable): + class P(cls.Basic): pass - class C(cls.Comparable): + class C(cls.Basic): pass @classmethod @@ -379,7 +380,7 @@ class RowSwitchTest(_base.MappedTest): p.c = C(data='child row-switch') session.commit() -class AlternateGeneratorTest(_base.MappedTest): +class AlternateGeneratorTest(fixtures.MappedTest): @classmethod def define_tables(cls, metadata): Table('p', metadata, @@ -395,9 +396,9 @@ class AlternateGeneratorTest(_base.MappedTest): @classmethod def setup_classes(cls): - class P(cls.Comparable): + class P(cls.Basic): pass - class C(cls.Comparable): + class C(cls.Basic): pass @classmethod @@ -481,7 +482,7 @@ class AlternateGeneratorTest(_base.MappedTest): ) -class InheritanceTwoVersionIdsTest(_base.MappedTest): +class InheritanceTwoVersionIdsTest(fixtures.MappedTest): """Test versioning where both parent/child table have a versioning column. @@ -501,7 +502,7 @@ class InheritanceTwoVersionIdsTest(_base.MappedTest): @classmethod def setup_classes(cls): - class Base(cls.Comparable): + class Base(cls.Basic): pass class Sub(Base): pass diff --git a/test/perf/sessions.py b/test/perf/sessions.py index 3384736a1b..75106f6ca2 100644 --- a/test/perf/sessions.py +++ b/test/perf/sessions.py @@ -2,14 +2,14 @@ from sqlalchemy import * from sqlalchemy.orm import * from test.lib.compat import gc_collect -from test.lib import TestBase, AssertsExecutionResults, profiling, testing +from test.lib import AssertsExecutionResults, profiling, testing from test.orm import _fixtures # in this test we are specifically looking for time spent in the attributes.InstanceState.__cleanup() method. ITERATIONS = 100 -class SessionTest(TestBase, AssertsExecutionResults): +class SessionTest(fixtures.TestBase, AssertsExecutionResults): @classmethod def setup_class(cls): global t1, t2, metadata,T1, T2 @@ -36,9 +36,9 @@ class SessionTest(TestBase, AssertsExecutionResults): l.append({'c2':'this is t2 #%d' % y, 't1id':x}) t2.insert().execute(*l) - class T1(_base.ComparableEntity): + class T1(fixtures.ComparableEntity): pass - class T2(_base.ComparableEntity): + class T2(fixtures.ComparableEntity): pass mapper(T1, t1, properties={ diff --git a/test/sql/_base.py b/test/sql/_base.py deleted file mode 100644 index 48879ae7e3..0000000000 --- a/test/sql/_base.py +++ /dev/null @@ -1,4 +0,0 @@ -from test.engine import _base as engine_base - - -TablesTest = engine_base.TablesTest diff --git a/test/sql/test_case_statement.py b/test/sql/test_case_statement.py index 4bb9cf0fc0..994016c2ff 100644 --- a/test/sql/test_case_statement.py +++ b/test/sql/test_case_statement.py @@ -6,7 +6,7 @@ from sqlalchemy import util, exc from sqlalchemy.sql import table, column -class CaseTest(TestBase, AssertsCompiledSQL): +class CaseTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = 'default' @classmethod diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index 69765a4fa6..412604c041 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -61,7 +61,7 @@ addresses = table('addresses', column('zip') ) -class SelectTest(TestBase, AssertsCompiledSQL): +class SelectTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = 'default' def test_attribute_sanity(self): @@ -2432,7 +2432,7 @@ class SelectTest(TestBase, AssertsCompiledSQL): ) -class CRUDTest(TestBase, AssertsCompiledSQL): +class CRUDTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = 'default' def test_insert(self): @@ -2688,7 +2688,7 @@ class CRUDTest(TestBase, AssertsCompiledSQL): "UPDATE foo SET id=:id, foo_id=:foo_id WHERE foo.id = :foo_id_1" ) -class InlineDefaultTest(TestBase, AssertsCompiledSQL): +class InlineDefaultTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = 'default' def test_insert(self): @@ -2722,7 +2722,7 @@ class InlineDefaultTest(TestBase, AssertsCompiledSQL): "coalesce(max(foo.id)) AS coalesce_1 FROM foo), " "col3=:col3") -class SchemaTest(TestBase, AssertsCompiledSQL): +class SchemaTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = 'default' def test_select(self): diff --git a/test/sql/test_constraints.py b/test/sql/test_constraints.py index c5433fa9c2..19aa7c1716 100644 --- a/test/sql/test_constraints.py +++ b/test/sql/test_constraints.py @@ -8,7 +8,7 @@ from test.lib.testing import eq_ from test.lib.assertsql import AllOf, RegexSQL, ExactSQL, CompiledSQL from sqlalchemy.dialects.postgresql import base as postgresql -class ConstraintTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL): +class ConstraintTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): def setup(self): global metadata @@ -255,7 +255,7 @@ class ConstraintTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL): Index('bar', t1.c.x) ) -class ConstraintCompilationTest(TestBase, AssertsCompiledSQL): +class ConstraintCompilationTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = 'default' def _test_deferrable(self, constraint_factory): diff --git a/test/sql/test_defaults.py b/test/sql/test_defaults.py index 2ba131ddc8..a28143f705 100644 --- a/test/sql/test_defaults.py +++ b/test/sql/test_defaults.py @@ -9,10 +9,10 @@ from sqlalchemy import MetaData, Integer, String, ForeignKey, Boolean, exc,\ from sqlalchemy.types import TypeDecorator from test.lib.schema import Table, Column from test.lib.testing import eq_ -from test.sql import _base from sqlalchemy.dialects import sqlite +from test.lib import fixtures -class DefaultTest(testing.TestBase): +class DefaultTest(fixtures.TestBase): @classmethod def setup_class(cls): @@ -393,7 +393,7 @@ class DefaultTest(testing.TestBase): eq_(55, l['col3']) -class PKDefaultTest(_base.TablesTest): +class PKDefaultTest(fixtures.TablesTest): __requires__ = ('subqueries',) @classmethod @@ -428,7 +428,7 @@ class PKDefaultTest(_base.TablesTest): r = engine.execute(t1.insert(), data='there') eq_([2], r.inserted_primary_key) -class PKIncrementTest(_base.TablesTest): +class PKIncrementTest(fixtures.TablesTest): run_define_tables = 'each' @classmethod @@ -495,7 +495,7 @@ class PKIncrementTest(_base.TablesTest): con.close() -class EmptyInsertTest(testing.TestBase): +class EmptyInsertTest(fixtures.TestBase): @testing.exclude('sqlite', '<', (3, 3, 8), 'no empty insert support') @testing.fails_on('oracle', 'FIXME: unknown') def test_empty_insert(self): @@ -511,7 +511,7 @@ class EmptyInsertTest(testing.TestBase): finally: metadata.drop_all() -class AutoIncrementTest(_base.TablesTest): +class AutoIncrementTest(fixtures.TablesTest): __requires__ = ('identity',) run_define_tables = 'each' @@ -561,7 +561,7 @@ class AutoIncrementTest(_base.TablesTest): nonai.insert().execute(id=1, data='row 1') -class SequenceDDLTest(testing.TestBase, testing.AssertsCompiledSQL): +class SequenceDDLTest(fixtures.TestBase, testing.AssertsCompiledSQL): __dialect__ = 'default' def test_create_drop_ddl(self): @@ -590,7 +590,7 @@ class SequenceDDLTest(testing.TestBase, testing.AssertsCompiledSQL): "DROP SEQUENCE foo_seq", ) -class SequenceExecTest(testing.TestBase): +class SequenceExecTest(fixtures.TestBase): __requires__ = ('sequences',) @classmethod @@ -720,7 +720,7 @@ class SequenceExecTest(testing.TestBase): ) self._assert_seq_result(r.inserted_primary_key[0]) -class SequenceTest(testing.TestBase, testing.AssertsCompiledSQL): +class SequenceTest(fixtures.TestBase, testing.AssertsCompiledSQL): __requires__ = ('sequences',) @testing.fails_on('firebird', 'no FB support for start/increment') @@ -833,7 +833,7 @@ class SequenceTest(testing.TestBase, testing.AssertsCompiledSQL): assert not self._has_sequence('s2') -class TableBoundSequenceTest(testing.TestBase): +class TableBoundSequenceTest(fixtures.TestBase): __requires__ = ('sequences',) @classmethod @@ -894,7 +894,7 @@ class TableBoundSequenceTest(testing.TestBase): (4, "name4", 4)]) -class SpecialTypePKTest(testing.TestBase): +class SpecialTypePKTest(fixtures.TestBase): """test process_result_value in conjunction with primary key columns. Also tests that "autoincrement" checks are against column.type._type_affinity, @@ -978,7 +978,7 @@ class SpecialTypePKTest(testing.TestBase): def test_server_default_no_implicit_returning(self): self._run_test(server_default='1', autoincrement=False) -class ServerDefaultsOnPKTest(testing.TestBase): +class ServerDefaultsOnPKTest(fixtures.TestBase): @testing.provide_metadata def test_string_default_none_on_insert(self): """Test that without implicit returning, we return None for @@ -1104,7 +1104,7 @@ class ServerDefaultsOnPKTest(testing.TestBase): [(5, 'data')] ) -class UnicodeDefaultsTest(testing.TestBase): +class UnicodeDefaultsTest(fixtures.TestBase): def test_no_default(self): c = Column(Unicode(32)) diff --git a/test/sql/test_functions.py b/test/sql/test_functions.py index 98d8d7a970..f08fde1f5d 100644 --- a/test/sql/test_functions.py +++ b/test/sql/test_functions.py @@ -15,7 +15,7 @@ from test.lib import testing from sqlalchemy.databases import * -class CompileTest(TestBase, AssertsCompiledSQL): +class CompileTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = 'default' def test_compile(self): @@ -190,7 +190,7 @@ class CompileTest(TestBase, AssertsCompiledSQL): , checkparams={'y_1': 45, 'x_1': 17, 'y_2': 12, 'x_2': 5}) -class ExecuteTest(TestBase): +class ExecuteTest(fixtures.TestBase): @engines.close_first def tearDown(self): pass diff --git a/test/sql/test_generative.py b/test/sql/test_generative.py index 088162c8a6..0634ded40b 100644 --- a/test/sql/test_generative.py +++ b/test/sql/test_generative.py @@ -7,7 +7,7 @@ from sqlalchemy import util from sqlalchemy.sql import util as sql_util from test.lib.testing import eq_ -class TraversalTest(TestBase, AssertsExecutionResults): +class TraversalTest(fixtures.TestBase, AssertsExecutionResults): """test ClauseVisitor's traversal, particularly its ability to copy and modify a ClauseElement in place.""" @@ -166,7 +166,7 @@ class TraversalTest(TestBase, AssertsExecutionResults): s = set(ClauseVisitor().iterate(bin)) assert set(ClauseVisitor().iterate(bin)) == set([foo, bar, bin]) -class ClauseTest(TestBase, AssertsCompiledSQL): +class ClauseTest(fixtures.TestBase, AssertsCompiledSQL): """test copy-in-place behavior of various ClauseElements.""" __dialect__ = 'default' @@ -472,7 +472,7 @@ class ClauseTest(TestBase, AssertsCompiledSQL): ':col1_1) AS anon_1 WHERE table1.col1 = ' 'anon_1.col1') -class ClauseAdapterTest(TestBase, AssertsCompiledSQL): +class ClauseAdapterTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = 'default' @classmethod @@ -861,7 +861,7 @@ class ClauseAdapterTest(TestBase, AssertsCompiledSQL): "WHERE c.bid = anon_1.b_aid" ) -class SpliceJoinsTest(TestBase, AssertsCompiledSQL): +class SpliceJoinsTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = 'default' @classmethod @@ -932,7 +932,7 @@ class SpliceJoinsTest(TestBase, AssertsCompiledSQL): 'table1.col3 = table4_1.col3') -class SelectTest(TestBase, AssertsCompiledSQL): +class SelectTest(fixtures.TestBase, AssertsCompiledSQL): """tests the generative capability of Select""" __dialect__ = 'default' @@ -1088,7 +1088,7 @@ class SelectTest(TestBase, AssertsCompiledSQL): s = text('select 42', execution_options=dict(foo='bar')) assert s._execution_options == dict(foo='bar') -class InsertTest(TestBase, AssertsCompiledSQL): +class InsertTest(fixtures.TestBase, AssertsCompiledSQL): """Tests the generative capability of Insert""" __dialect__ = 'default' diff --git a/test/sql/test_labels.py b/test/sql/test_labels.py index 9160aa3ee5..9f26d899f4 100644 --- a/test/sql/test_labels.py +++ b/test/sql/test_labels.py @@ -6,7 +6,7 @@ from sqlalchemy.engine import default IDENT_LENGTH = 29 -class LabelTypeTest(TestBase): +class LabelTypeTest(fixtures.TestBase): def test_type(self): m = MetaData() t = Table('sometable', m, @@ -15,7 +15,7 @@ class LabelTypeTest(TestBase): assert isinstance(t.c.col1.label('hi').type, Integer) assert isinstance(select([t.c.col2]).as_scalar().label('lala').type, Float) -class LongLabelsTest(TestBase, AssertsCompiledSQL): +class LongLabelsTest(fixtures.TestBase, AssertsCompiledSQL): @classmethod def setup_class(cls): global metadata, table1, table2, maxlen diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py index 7040cacffd..77a75eb5f5 100644 --- a/test/sql/test_metadata.py +++ b/test/sql/test_metadata.py @@ -10,11 +10,13 @@ from sqlalchemy import Integer, String, UniqueConstraint, \ from test.lib.schema import Table, Column from sqlalchemy import schema, exc import sqlalchemy as tsa -from test.lib import TestBase, ComparesTables, \ - AssertsCompiledSQL, testing, engines +from test.lib import fixtures +from test.lib import testing +from test.lib import engines +from test.lib.testing import ComparesTables, AssertsCompiledSQL from test.lib.testing import eq_ -class MetaDataTest(TestBase, ComparesTables): +class MetaDataTest(fixtures.TestBase, ComparesTables): def test_metadata_connect(self): metadata = MetaData() t1 = Table('table1', metadata, @@ -515,7 +517,7 @@ class MetaDataTest(TestBase, ComparesTables): MetaData(testing.db), autoload=True) -class TableTest(TestBase, AssertsCompiledSQL): +class TableTest(fixtures.TestBase, AssertsCompiledSQL): def test_prefixes(self): table1 = Table("temporary_table_1", MetaData(), Column("col1", Integer), @@ -568,7 +570,7 @@ class TableTest(TestBase, AssertsCompiledSQL): assign ) -class ConstraintTest(TestBase): +class ConstraintTest(fixtures.TestBase): def _single_fixture(self): m = MetaData() @@ -615,7 +617,7 @@ class ConstraintTest(TestBase): assert s1.c.a.references(t1.c.a) assert not s1.c.a.references(t1.c.b) -class ColumnDefinitionTest(AssertsCompiledSQL, TestBase): +class ColumnDefinitionTest(AssertsCompiledSQL, fixtures.TestBase): """Test Column() construction.""" __dialect__ = 'default' @@ -739,7 +741,7 @@ class ColumnDefinitionTest(AssertsCompiledSQL, TestBase): getattr, select([t1.select().alias()]), 'c' ) -class ColumnOptionsTest(TestBase): +class ColumnOptionsTest(fixtures.TestBase): def test_default_generators(self): g1, g2 = Sequence('foo_id_seq'), ColumnDefault('f5') @@ -776,7 +778,7 @@ class ColumnOptionsTest(TestBase): assert c.info['bar'] == 'zip' -class CatchAllEventsTest(TestBase): +class CatchAllEventsTest(fixtures.TestBase): def teardown(self): events.SchemaEventTarget.dispatch._clear() diff --git a/test/sql/test_query.py b/test/sql/test_query.py index da5b05d0a8..2edf9e72dd 100644 --- a/test/sql/test_query.py +++ b/test/sql/test_query.py @@ -6,7 +6,7 @@ from sqlalchemy.engine import default, base from test.lib import * from test.lib.schema import Table, Column -class QueryTest(TestBase): +class QueryTest(fixtures.TestBase): @classmethod def setup_class(cls): @@ -1029,7 +1029,7 @@ class QueryTest(TestBase): r = s.execute().fetchall() assert len(r) == 1 -class PercentSchemaNamesTest(TestBase): +class PercentSchemaNamesTest(fixtures.TestBase): """tests using percent signs, spaces in table and column names. Doesn't pass for mysql, postgresql, but this is really a @@ -1129,7 +1129,7 @@ class PercentSchemaNamesTest(TestBase): -class LimitTest(TestBase): +class LimitTest(fixtures.TestBase): @classmethod def setup_class(cls): @@ -1202,7 +1202,7 @@ class LimitTest(TestBase): self.assert_(len(r) == 3, repr(r)) self.assert_(r[0] != r[1] and r[1] != r[2], repr(r)) -class CompoundTest(TestBase): +class CompoundTest(fixtures.TestBase): """test compound statements like UNION, INTERSECT, particularly their ability to nest on different databases.""" @classmethod @@ -1494,7 +1494,7 @@ class CompoundTest(TestBase): eq_(found, wanted) -class JoinTest(TestBase): +class JoinTest(fixtures.TestBase): """Tests join execution. The compiled SQL emitted by the dialect might be ANSI joins or @@ -1766,7 +1766,7 @@ class JoinTest(TestBase): self.assertRows(expr, [(10, 20, 30)]) -class OperatorTest(TestBase): +class OperatorTest(fixtures.TestBase): @classmethod def setup_class(cls): global metadata, flds diff --git a/test/sql/test_quote.py b/test/sql/test_quote.py index b31e7dfb4e..6caf55d914 100644 --- a/test/sql/test_quote.py +++ b/test/sql/test_quote.py @@ -3,7 +3,7 @@ from sqlalchemy import sql, schema from sqlalchemy.sql import compiler from test.lib import * -class QuoteTest(TestBase, AssertsCompiledSQL): +class QuoteTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = 'default' @classmethod @@ -182,7 +182,7 @@ class QuoteTest(TestBase, AssertsCompiledSQL): '''SELECT "ImATable".col1, "ImATable"."from", "ImATable".louisville, "ImATable"."order" FROM "ImATable"''') -class PreparerTest(TestBase): +class PreparerTest(fixtures.TestBase): """Test the db-agnostic quoting services of IdentifierPreparer.""" def test_unformat(self): diff --git a/test/sql/test_returning.py b/test/sql/test_returning.py index 8c4e2ac3c6..3ef6dc9d93 100644 --- a/test/sql/test_returning.py +++ b/test/sql/test_returning.py @@ -3,8 +3,9 @@ from sqlalchemy import * from test.lib import * from test.lib.schema import Table, Column from sqlalchemy.types import TypeDecorator +from test.lib import fixtures -class ReturningTest(TestBase, AssertsExecutionResults): +class ReturningTest(fixtures.TestBase, AssertsExecutionResults): __requires__ = 'returning', def setup(self): @@ -141,7 +142,7 @@ class ReturningTest(TestBase, AssertsExecutionResults): result2 = select([table.c.id, table.c.full]).order_by(table.c.id).execute() eq_(result2.fetchall(), [(2,False),]) -class SequenceReturningTest(TestBase): +class SequenceReturningTest(fixtures.TestBase): __requires__ = 'returning', def setup(self): @@ -162,7 +163,7 @@ class SequenceReturningTest(TestBase): assert r.first() == (1, ) assert seq.execute() == 2 -class KeyReturningTest(TestBase, AssertsExecutionResults): +class KeyReturningTest(fixtures.TestBase, AssertsExecutionResults): """test returning() works with columns that define 'key'.""" __requires__ = 'returning', @@ -191,7 +192,7 @@ class KeyReturningTest(TestBase, AssertsExecutionResults): assert row[table.c.foo_id] == row['id'] == 1 -class ImplicitReturningFlag(TestBase): +class ImplicitReturningFlag(fixtures.TestBase): def test_flag_turned_off(self): e = engines.testing_engine(options={'implicit_returning':False}) assert e.dialect.implicit_returning is False diff --git a/test/sql/test_rowcount.py b/test/sql/test_rowcount.py index fc74e84675..5d95baa81c 100644 --- a/test/sql/test_rowcount.py +++ b/test/sql/test_rowcount.py @@ -2,7 +2,7 @@ from sqlalchemy import * from test.lib import * -class FoundRowsTest(TestBase, AssertsExecutionResults): +class FoundRowsTest(fixtures.TestBase, AssertsExecutionResults): """tests rowcount functionality""" __requires__ = ('sane_rowcount', ) diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py index 243c56dcf7..0e98a430aa 100644 --- a/test/sql/test_selectable.py +++ b/test/sql/test_selectable.py @@ -8,6 +8,7 @@ from sqlalchemy.sql import util as sql_util, visitors from sqlalchemy import exc from sqlalchemy.sql import table, column, null from sqlalchemy import util +from test.lib import fixtures metadata = MetaData() table1 = Table('table1', metadata, @@ -26,7 +27,7 @@ table2 = Table('table2', metadata, ) -class SelectableTest(TestBase, AssertsExecutionResults): +class SelectableTest(fixtures.TestBase, AssertsExecutionResults): def test_indirect_correspondence_on_labels(self): # this test depends upon 'distance' to @@ -372,7 +373,7 @@ class SelectableTest(TestBase, AssertsExecutionResults): t1t2.join, t2t3.select(use_labels=True)) -class PrimaryKeyTest(TestBase, AssertsExecutionResults): +class PrimaryKeyTest(fixtures.TestBase, AssertsExecutionResults): def test_join_pk_collapse_implicit(self): """test that redundant columns in a join get 'collapsed' into a @@ -476,7 +477,7 @@ class PrimaryKeyTest(TestBase, AssertsExecutionResults): util.column_set([employee.c.id])) -class ReduceTest(TestBase, AssertsExecutionResults): +class ReduceTest(fixtures.TestBase, AssertsExecutionResults): def test_reduce(self): meta = MetaData() t1 = Table('t1', meta, @@ -635,7 +636,7 @@ class ReduceTest(TestBase, AssertsExecutionResults): pjoin.c.page_id, pjoin.c.magazine_page_id])), util.column_set([pjoin.c.id])) -class DerivedTest(TestBase, AssertsExecutionResults): +class DerivedTest(fixtures.TestBase, AssertsExecutionResults): def test_table(self): meta = MetaData() @@ -677,7 +678,7 @@ class DerivedTest(TestBase, AssertsExecutionResults): assert select([t1, t2]).alias('foo').is_derived_from(t1) assert not t2.select().alias('foo').is_derived_from(t1) -class AnnotationsTest(TestBase): +class AnnotationsTest(fixtures.TestBase): def test_custom_constructions(self): from sqlalchemy.schema import Column class MyColumn(Column): diff --git a/test/sql/test_types.py b/test/sql/test_types.py index 9c8f66328c..6aeac9b645 100644 --- a/test/sql/test_types.py +++ b/test/sql/test_types.py @@ -14,9 +14,9 @@ from test.lib import * from test.lib.util import picklers from sqlalchemy.util.compat import decimal from test.lib.util import round_decimal -from test.engine import _base +from test.lib import fixtures -class AdaptTest(TestBase): +class AdaptTest(fixtures.TestBase): def _all_dialect_modules(self): return [ getattr(dialects, d) @@ -131,7 +131,7 @@ class AdaptTest(TestBase): typ, 11 ) -class TypeAffinityTest(TestBase): +class TypeAffinityTest(fixtures.TestBase): def test_type_affinity(self): for type_, affin in [ (String(), String), @@ -154,7 +154,7 @@ class TypeAffinityTest(TestBase): ]: eq_(t1._compare_type_affinity(t2), comp, "%s %s" % (t1, t2)) -class PickleMetadataTest(TestBase): +class PickleMetadataTest(fixtures.TestBase): def testmeta(self): for loads, dumps in picklers(): column_types = [ @@ -183,7 +183,7 @@ class PickleMetadataTest(TestBase): mt = loads(dumps(meta)) -class UserDefinedTest(_base.TablesTest, AssertsCompiledSQL): +class UserDefinedTest(fixtures.TablesTest, AssertsCompiledSQL): """tests user-defined types.""" def test_processing(self): @@ -423,7 +423,7 @@ class UserDefinedTest(_base.TablesTest, AssertsCompiledSQL): ) -class UnicodeTest(TestBase, AssertsExecutionResults): +class UnicodeTest(fixtures.TestBase, AssertsExecutionResults): """tests the Unicode type. also tests the TypeDecorator with instances in the types package.""" @classmethod @@ -680,7 +680,7 @@ class UnicodeTest(TestBase, AssertsExecutionResults): m.drop_all(engine) -class EnumTest(TestBase): +class EnumTest(fixtures.TestBase): @classmethod def setup_class(cls): global enum_table, non_native_enum_table, metadata @@ -770,7 +770,7 @@ class EnumTest(TestBase): {'id':4, 'someenum':'four'} ) -class BinaryTest(TestBase, AssertsExecutionResults): +class BinaryTest(fixtures.TestBase, AssertsExecutionResults): __excluded_on__ = ( ('mysql', '<', (4, 1, 1)), # screwy varbinary types ) @@ -873,7 +873,7 @@ class BinaryTest(TestBase, AssertsExecutionResults): f = os.path.join(os.path.dirname(__file__), "..", name) return open(f, mode='rb').read() -class ExpressionTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL): +class ExpressionTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): __dialect__ = 'default' @classmethod @@ -1140,7 +1140,7 @@ class ExpressionTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL): assert distinct(test_table.c.data).type == test_table.c.data.type assert test_table.c.data.distinct().type == test_table.c.data.type -class CompileTest(TestBase, AssertsCompiledSQL): +class CompileTest(fixtures.TestBase, AssertsCompiledSQL): def test_default_compile(self): """test that the base dialect of the type object is used for default compilation. @@ -1159,7 +1159,7 @@ class CompileTest(TestBase, AssertsCompiledSQL): self.assert_compile(type_, expected, allow_dialect_select=True) -class DateTest(TestBase, AssertsExecutionResults): +class DateTest(fixtures.TestBase, AssertsExecutionResults): @classmethod def setup_class(cls): global users_with_date, insert_data @@ -1294,7 +1294,7 @@ class DateTest(TestBase, AssertsExecutionResults): finally: t.drop(checkfirst=True) -class StringTest(TestBase): +class StringTest(fixtures.TestBase): @testing.requires.unbounded_varchar def test_nolength_string(self): @@ -1304,7 +1304,7 @@ class StringTest(TestBase): foo.create() foo.drop() -class NumericTest(TestBase): +class NumericTest(fixtures.TestBase): def setup(self): global metadata metadata = MetaData(testing.db) @@ -1443,7 +1443,7 @@ class NumericTest(TestBase): numbers ) -class NumericRawSQLTest(TestBase): +class NumericRawSQLTest(fixtures.TestBase): """Test what DBAPIs and dialects return without any typing information supplied at the SQLA level. @@ -1497,7 +1497,7 @@ class NumericRawSQLTest(TestBase): -class IntervalTest(TestBase, AssertsExecutionResults): +class IntervalTest(fixtures.TestBase, AssertsExecutionResults): @classmethod def setup_class(cls): global interval_table, metadata @@ -1550,7 +1550,7 @@ class IntervalTest(TestBase, AssertsExecutionResults): eq_(row['non_native_interval'], None) -class BooleanTest(TestBase, AssertsExecutionResults): +class BooleanTest(fixtures.TestBase, AssertsExecutionResults): @classmethod def setup_class(cls): global bool_table @@ -1612,7 +1612,7 @@ class BooleanTest(TestBase, AssertsExecutionResults): testing.db.execute( "insert into booltest (id, unconstrained_value) values (1, 5)") -class PickleTest(TestBase): +class PickleTest(fixtures.TestBase): def test_eq_comparison(self): p1 = PickleType() @@ -1638,7 +1638,7 @@ class PickleTest(TestBase): ): assert p1.compare_values(p1.copy_value(obj), obj) -class CallableTest(TestBase): +class CallableTest(fixtures.TestBase): @classmethod def setup_class(cls): global meta diff --git a/test/sql/test_unicode.py b/test/sql/test_unicode.py index d6757caf1a..19f672f77e 100644 --- a/test/sql/test_unicode.py +++ b/test/sql/test_unicode.py @@ -2,11 +2,12 @@ """verrrrry basic unicode column name testing""" from sqlalchemy import * -from test.lib import * +from test.lib import fixtures, engines, testing from test.lib.engines import utf8_engine from sqlalchemy.sql import column +from test.lib.schema import Table, Column -class UnicodeSchemaTest(TestBase): +class UnicodeSchemaTest(fixtures.TestBase): __requires__ = ('unicode_ddl',) @classmethod @@ -111,7 +112,7 @@ class UnicodeSchemaTest(TestBase): meta.drop_all() metadata.create_all() -class EscapesDefaultsTest(testing.TestBase): +class EscapesDefaultsTest(fixtures.TestBase): def test_default_exec(self): metadata = MetaData(testing.db) t1 = Table('t1', metadata,