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)
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]
from test.lib import *
from sqlalchemy.engine import default
-class CompileTest(TestBase, AssertsExecutionResults):
+class CompileTest(fixtures.TestBase, AssertsExecutionResults):
@classmethod
def setup_class(cls):
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):
gc_collect()
assert len(_mapper_registry) == 0
-class EnsureZeroed(_base.ORMTest):
+class EnsureZeroed(fixtures.ORMTest):
def setup(self):
_sessions.clear()
_mapper_registry.clear()
@profile_memory
def go():
- class A(_base.ComparableEntity):
+ class A(fixtures.ComparableEntity):
pass
class B(A):
pass
@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={
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):
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
from sqlalchemy.pool import QueuePool
-class QueuePoolTest(TestBase, AssertsExecutionResults):
+class QueuePoolTest(fixtures.TestBase, AssertsExecutionResults):
class Connection(object):
def rollback(self):
pass
NUM_RECORDS = 1000
-class ResultSetTest(TestBase, AssertsExecutionResults):
+class ResultSetTest(fixtures.TestBase, AssertsExecutionResults):
__only_on__ = 'sqlite'
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):
metadata = None
-class ZooMarkTest(TestBase):
+class ZooMarkTest(fixtures.TestBase):
"""Runs the ZooMark and squawks if method counts vary from the norm.
metadata = None
-class ZooMarkTest(TestBase):
+class ZooMarkTest(fixtures.TestBase):
"""Runs the ZooMark and squawks if method counts vary from the norm.
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:
"""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):
[listen_three, listen_one, listen_two]
)
-class TestAcceptTargets(TestBase):
+class TestAcceptTargets(fixtures.TestBase):
"""Test default target acceptance."""
def setUp(self):
[listen_two, listen_four]
)
-class TestCustomTargets(TestBase):
+class TestCustomTargets(fixtures.TestBase):
"""Test custom target acceptance."""
def setUp(self):
listen, "event_one", Target
)
-class TestListenOverride(TestBase):
+class TestListenOverride(fixtures.TestBase):
"""Test custom listen functions which change the listener function signature."""
def setUp(self):
]
)
-class TestPropagate(TestBase):
+class TestPropagate(fixtures.TestBase):
def setUp(self):
global Target
from sqlalchemy import exc as sa_exceptions
-from test.lib import TestBase
+from test.lib import fixtures
# Py3K
#StandardError = BaseException
pass
-class WrapTest(TestBase):
+class WrapTest(fixtures.TestBase):
def test_db_error_normal(self):
try:
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
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])
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):
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'))
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):
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,
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])
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]
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):
self._notok(duck6())
-class DuckTypeCollectionTest(TestBase):
+class DuckTypeCollectionTest(fixtures.TestBase):
def test_sets(self):
# Py2K
import sets
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):
test(f3)
test(f4)
-class SymbolTest(TestBase):
+class SymbolTest(fixtures.TestBase):
def test_basic(self):
sym1 = util.symbol('foo')
assert sym1.name == 'foo'
assert rt is sym1
assert rt is sym2
-class WeakIdentityMappingTest(TestBase):
+class WeakIdentityMappingTest(fixtures.TestBase):
class Data(object):
pass
eq_(wim._weakrefs, {})
-class TestFormatArgspec(TestBase):
+class TestFormatArgspec(fixtures.TestBase):
def test_specs(self):
def test(fn, wanted, grouped=None):
if grouped is None:
test(O.__init__, custom_spec)
-class AsInterfaceTest(TestBase):
+class AsInterfaceTest(fixtures.TestBase):
class Something(object):
def _ignoreme(self): pass
cls=self.Something)
-class TestClassHierarchy(TestBase):
+class TestClassHierarchy(fixtures.TestBase):
def test_object(self):
eq_(set(util.class_hierarchy(object)), set((object,)))
# end Py2K
-class TestClassProperty(TestBase):
+class TestClassProperty(fixtures.TestBase):
def test_simple(self):
class A(object):
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
"""
- 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__):
from test.lib import *
-class CompileTest(TestBase, AssertsCompiledSQL):
+class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = access.dialect()
def test_extract(self):
from test.lib import *
-class DomainReflectionTest(TestBase, AssertsExecutionResults):
+class DomainReflectionTest(fixtures.TestBase, AssertsExecutionResults):
"Test Firebird domains"
__only_on__ = 'firebird'
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"""
eq_(table_b.c.id.server_default.arg.text, "0")
-class CompileTest(TestBase, AssertsCompiledSQL):
+class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = firebird.FBDialect()
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
[(float('inf'),)]
)
-class MiscTest(TestBase):
+class MiscTest(fixtures.TestBase):
__only_on__ = 'firebird'
from test.lib import *
-class CompileTest(TestBase, AssertsCompiledSQL):
+class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = informix.InformixDialect()
# - 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'
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!
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):
-class IdentityInsertTest(TestBase, AssertsCompiledSQL):
+class IdentityInsertTest(fixtures.TestBase, AssertsCompiledSQL):
__only_on__ = 'mssql'
__dialect__ = mssql.MSDialect()
eq_([(91, 'Smalltalk'), (90, 'PHP')], list(lastcats))
-class ReflectionTest(TestBase, ComparesTables):
+class ReflectionTest(fixtures.TestBase, ComparesTables):
__only_on__ = 'mssql'
def test_basic_reflection(self):
set([t2.c['x col'], t2.c.y])
)
-class QueryUnicodeTest(TestBase):
+class QueryUnicodeTest(fixtures.TestBase):
__only_on__ = 'mssql'
finally:
meta.drop_all()
-class QueryTest(TestBase):
+class QueryTest(fixtures.TestBase):
__only_on__ = 'mssql'
def test_fetchid_trigger(self):
for k in kw:
setattr(self, k, kw[k])
-class GenerativeQueryTest(TestBase):
+class GenerativeQueryTest(fixtures.TestBase):
__only_on__ = 'mssql'
@classmethod
assert list(query[:10]) == orig[:10]
-class SchemaTest(TestBase):
+class SchemaTest(fixtures.TestBase):
def setup(self):
t = Table('sometable', MetaData(),
finally:
connection.close()
-class MatchTest(TestBase, AssertsCompiledSQL):
+class MatchTest(fixtures.TestBase, AssertsCompiledSQL):
__only_on__ = 'mssql'
__skip_if__ = full_text_search_missing,
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
'Unrecognized server version info',
engine.connect)
-class TypesTest(TestBase, AssertsExecutionResults, ComparesTables):
+class TypesTest(fixtures.TestBase, AssertsExecutionResults, ComparesTables):
__only_on__ = 'mssql'
@classmethod
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'
return stream
-class ReflectHugeViewTest(TestBase):
+class ReflectHugeViewTest(fixtures.TestBase):
__only_on__ = 'mssql'
def setup(self):
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
def close(self):
pass
-class MxODBCTest(TestBase):
+class MxODBCTest(fixtures.TestBase):
def test_native_odbc_execute(self):
t1 = Table('t1', MetaData(), Column('c1', Integer))
from test.lib.engines import utf8_engine
import datetime
-class CompileTest(TestBase, AssertsCompiledSQL):
+class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = mysql.dialect()
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'],
}
)
-class TypesTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL):
+class TypesTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL):
"Test MySQL column types"
__only_on__ = 'mysql'
finally:
enum_table.drop()
-class ReflectionTest(TestBase, AssertsExecutionResults):
+class ReflectionTest(fixtures.TestBase, AssertsExecutionResults):
__only_on__ = 'mysql'
-class SQLTest(TestBase, AssertsCompiledSQL):
+class SQLTest(fixtures.TestBase, AssertsCompiledSQL):
"""Tests MySQL-dialect specific compilation."""
__dialect__ = mysql.dialect()
'INTEGER NOT NULL, PRIMARY KEY '
'(assigned_id, id))ENGINE=InnoDB')
-class SQLModeDetectionTest(TestBase):
+class SQLModeDetectionTest(fixtures.TestBase):
__only_on__ = 'mysql'
def _options(self, modes):
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)
assert regex.match(' PRIMARY KEY (`id`) USING BTREE')
-class ExecutionTest(TestBase):
+class ExecutionTest(fixtures.TestBase):
"""Various MySQL execution special cases."""
__only_on__ = 'mysql'
d = testing.db.scalar(func.sysdate())
assert isinstance(d, datetime.datetime)
-class MatchTest(TestBase, AssertsCompiledSQL):
+class MatchTest(fixtures.TestBase, AssertsCompiledSQL):
__only_on__ = 'mysql'
@classmethod
import os
-class OutParamTest(TestBase, AssertsExecutionResults):
+class OutParamTest(fixtures.TestBase, AssertsExecutionResults):
__only_on__ = 'oracle+cx_oracle'
@classmethod
testing.db.execute("DROP PROCEDURE foo")
-class CompileTest(TestBase, AssertsCompiledSQL):
+class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = oracle.OracleDialect()
]:
self.assert_compile(fn, expected)
-class CompatFlagsTest(TestBase, AssertsCompiledSQL):
+class CompatFlagsTest(fixtures.TestBase, AssertsCompiledSQL):
__only_on__ = 'oracle'
def test_ora8_flags(self):
self.assert_compile(UnicodeText(),"NCLOB",dialect=dialect)
-class MultiSchemaTest(TestBase, AssertsCompiledSQL):
+class MultiSchemaTest(fixtures.TestBase, AssertsCompiledSQL):
__only_on__ = 'oracle'
@classmethod
select([parent,
child]).select_from(parent.join(child)).execute().fetchall()
-class ConstraintTest(TestBase):
+class ConstraintTest(fixtures.TestBase):
__only_on__ = 'oracle'
onupdate='CASCADE'))
assert_raises(exc.SAWarning, bat.create)
-class TypesTest(TestBase, AssertsCompiledSQL):
+class TypesTest(fixtures.TestBase, AssertsCompiledSQL):
__only_on__ = 'oracle'
__dialect__ = oracle.OracleDialect()
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'
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."""
set(['admin_docindex'])
)
-class BufferedColumnTest(TestBase, AssertsCompiledSQL):
+class BufferedColumnTest(fixtures.TestBase, AssertsCompiledSQL):
__only_on__ = 'oracle'
@classmethod
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):
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):
-class SequenceTest(TestBase, AssertsCompiledSQL):
+class SequenceTest(fixtures.TestBase, AssertsCompiledSQL):
def test_basic(self):
seq = Sequence('my_seq_no_schema')
== '"Some_Schema"."My_Seq"'
-class ExecuteTest(TestBase):
+class ExecuteTest(fixtures.TestBase):
__only_on__ = 'oracle'
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')
r = engine.execute(t.insert())
assert r.inserted_primary_key == [1]
-class CompileTest(TestBase, AssertsCompiledSQL):
+class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = postgresql.dialect()
'''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()
([5], [5], [6], [decimal.Decimal("6.4")])
)
-class EnumTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL):
+class EnumTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL):
__only_on__ = 'postgresql'
__dialect__ = postgresql.dialect()
finally:
metadata.drop_all()
-class NumericInterpretationTest(TestBase):
+class NumericInterpretationTest(fixtures.TestBase):
__only_on__ = 'postgresql'
def test_numeric_codes(self):
(1, decimal.Decimal("1"), 1, decimal.Decimal("1"), 1)
)
-class InsertTest(TestBase, AssertsExecutionResults):
+class InsertTest(fixtures.TestBase, AssertsExecutionResults):
__only_on__ = 'postgresql'
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"""
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.
"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'
"c %s NOT NULL" % expected
)
-class TimezoneTest(TestBase):
+class TimezoneTest(fixtures.TestBase):
"""Test timezone-aware datetimes.
row = result.first()
assert row[0] >= somedate
-class TimePrecisionTest(TestBase, AssertsCompiledSQL):
+class TimePrecisionTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = postgresql.dialect()
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'
-class TimestampTest(TestBase, AssertsExecutionResults):
+class TimestampTest(fixtures.TestBase, AssertsExecutionResults):
__only_on__ = 'postgresql'
def test_timestamp(self):
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'
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'
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'
eq_(r.fetchone(), None)
-class MatchTest(TestBase, AssertsCompiledSQL):
+class MatchTest(fixtures.TestBase, AssertsCompiledSQL):
__only_on__ = 'postgresql'
__excluded_on__ = ('postgresql', '<', (8, 3, 0)),
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):
from test.lib import *
import os
-class TestTypes(TestBase, AssertsExecutionResults):
+class TestTypes(fixtures.TestBase, AssertsExecutionResults):
__only_on__ = 'sqlite'
assert isinstance(t2.c.y.type, sqltypes.NullType)
-class TestDefaults(TestBase, AssertsExecutionResults):
+class TestDefaults(fixtures.TestBase, AssertsExecutionResults):
__only_on__ = 'sqlite'
db.execute('DROP TABLE r_defaults')
-class DialectTest(TestBase, AssertsExecutionResults):
+class DialectTest(fixtures.TestBase, AssertsExecutionResults):
__only_on__ = 'sqlite'
meta.drop_all()
-class SQLTest(TestBase, AssertsCompiledSQL):
+class SQLTest(fixtures.TestBase, AssertsCompiledSQL):
"""Tests SQLite-dialect specific compilation."""
)
-class InsertTest(TestBase, AssertsExecutionResults):
+class InsertTest(fixtures.TestBase, AssertsExecutionResults):
"""Tests inserts and autoincrement."""
return True
-class MatchTest(TestBase, AssertsCompiledSQL):
+class MatchTest(fixtures.TestBase, AssertsCompiledSQL):
__only_on__ = 'sqlite'
__skip_if__ = full_text_search_missing,
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,
from test.lib import *
-class CompileTest(TestBase, AssertsCompiledSQL):
+class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = sybase.dialect()
def test_extract(self):
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,
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
'blah', fn)
-class DDLExecutionTest(TestBase):
+class DDLExecutionTest(fixtures.TestBase):
def setup(self):
self.engine = engines.mock_engine()
self.metadata = MetaData(self.engine)
-class DDLTest(TestBase, AssertsCompiledSQL):
+class DDLTest(fixtures.TestBase, AssertsCompiledSQL):
def mock_engine(self):
executor = lambda *a, **kw: None
engine = create_engine(testing.db.name + '://',
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
eq_(conn._execution_options['foo'], 'hoho')
-class CompiledCacheTest(TestBase):
+class CompiledCacheTest(fixtures.TestBase):
@classmethod
def setup_class(cls):
global users, metadata
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]:
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
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."""
writer.writerow(row)
assert s.getvalue().strip() == '1,Test'
-class AlternateResultProxyTest(TestBase):
+class AlternateResultProxyTest(fixtures.TestBase):
__requires__ = ('sqlite', )
@classmethod
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()
)
-class ProxyConnectionTest(TestBase):
+class ProxyConnectionTest(fixtures.TestBase):
"""These are the same tests as EngineEventsTest, except using
the deprecated ConnectionProxy interface.
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',
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.
'%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"""
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):
def close(self):
pass
-class PoolTestBase(TestBase):
+class PoolTestBase(fixtures.TestBase):
def setup(self):
pool.clear_managers()
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
pass
db, dbapi = None, None
-class MockReconnectTest(TestBase):
+class MockReconnectTest(fixtures.TestBase):
def setup(self):
global db, dbapi
dbapi = MockDBAPI()
assert not conn.invalidated
assert len(dbapi.connections) == 1
-class CursorErrTest(TestBase):
+class CursorErrTest(fixtures.TestBase):
def setup(self):
global db, dbapi
db.dispose()
engine = None
-class RealReconnectTest(TestBase):
+class RealReconnectTest(fixtures.TestBase):
def setup(self):
global engine
engine = engines.reconnecting_engine()
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:
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()
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+')
finally:
_drop_views(metadata.bind)
-class CreateDropTest(TestBase):
+class CreateDropTest(fixtures.TestBase):
@classmethod
def setup_class(cls):
- 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()
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):
bind.dispose()
-class SchemaTest(TestBase):
+class SchemaTest(fixtures.TestBase):
def test_iteration(self):
metadata = MetaData()
metadata.drop_all()
-class HasSequenceTest(TestBase):
+class HasSequenceTest(fixtures.TestBase):
@testing.requires.sequences
def test_has_sequence(self):
con.execute(sa.sql.text(query))
-class ReverseCasingReflectTest(TestBase, AssertsCompiledSQL):
+class ReverseCasingReflectTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = 'default'
@testing.requires.denormalized_names
'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):
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()
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
eq_(result.fetchall(), [('user1', ), ('user4', )])
conn.close()
-class AutoRollbackTest(TestBase):
+class AutoRollbackTest(fixtures.TestBase):
@classmethod
def setup_class(cls):
users.drop(conn2)
conn2.close()
-class ExplicitAutoCommitTest(TestBase):
+class ExplicitAutoCommitTest(fixtures.TestBase):
"""test the 'autocommit' flag on select() and text() objects.
tlengine = None
-class TLTransactionTest(TestBase):
+class TLTransactionTest(fixtures.TestBase):
@classmethod
def setup_class(cls):
counters = None
-class ForUpdateTest(TestBase):
+class ForUpdateTest(fixtures.TestBase):
@classmethod
def setup_class(cls):
update_style='nowait')
self.assert_(len(errors) != 0)
-class IsolationLevelTest(TestBase):
+class IsolationLevelTest(fixtures.TestBase):
__requires__ = ('isolation_level',)
def _default_isolation_level(self):
__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.
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):
return iter(self.values)
-class _CollectionOperations(TestBase):
+class _CollectionOperations(fixtures.TestBase):
def setup(self):
collection_class = self.collection_class
self._test_sequence_ops()
-class ScalarTest(TestBase):
+class ScalarTest(fixtures.TestBase):
def test_scalar_proxy(self):
metadata = MetaData(testing.db)
p2.bar = 'quux'
-class LazyLoadTest(TestBase):
+class LazyLoadTest(fixtures.TestBase):
def setup(self):
metadata = MetaData(testing.db)
self.name = name
self.value = value
-class ReconstitutionTest(TestBase):
+class ReconstitutionTest(fixtures.TestBase):
def setup(self):
metadata = MetaData(testing.db)
def __call__(self, obj):
return getattr(obj, self.name)
-class ComparatorTest(_base.MappedTest):
+class ComparatorTest(fixtures.MappedTest):
run_inserts = 'once'
run_deletes = None
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):
)
-class DefaultOnExistingTest(TestBase, AssertsCompiledSQL):
+class DefaultOnExistingTest(fixtures.TestBase, AssertsCompiledSQL):
"""Test replacement of default compilation on existing constructs."""
__dialect__ = 'default'
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)
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,
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,
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)
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,
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,
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)
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',
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)
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)
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)
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)
def test_string_dependency_resolution_tables(self):
- class User(Base, ComparableEntity):
+ class User(Base, fixtures.ComparableEntity):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
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)
def test_uncompiled_attributes_in_relationship(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(Integer, primary_key=True,
def test_add_prop(self):
- class User(Base, ComparableEntity):
+ class User(Base, fixtures.ComparableEntity):
__tablename__ = 'users'
id = Column('id', Integer, primary_key=True,
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,
def test_eager_order_by(self):
- class Address(Base, ComparableEntity):
+ class Address(Base, fixtures.ComparableEntity):
__tablename__ = 'addresses'
id = Column('id', Integer, primary_key=True,
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,
def test_order_by_multi(self):
- class Address(Base, ComparableEntity):
+ class Address(Base, fixtures.ComparableEntity):
__tablename__ = 'addresses'
id = Column('id', Integer, primary_key=True,
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,
def test_as_declarative(self):
- class User(ComparableEntity):
+ class User(fixtures.ComparableEntity):
__tablename__ = 'users'
id = Column('id', Integer, primary_key=True,
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,
def define():
- class User(Base, ComparableEntity):
+ class User(Base, fixtures.ComparableEntity):
__tablename__ = 'users'
id = Column('id', Integer, primary_key=True),
def test_expression(self):
- class User(Base, ComparableEntity):
+ class User(Base, fixtures.ComparableEntity):
__tablename__ = 'users'
id = Column('id', Integer, primary_key=True,
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,
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,
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,
def test_column(self):
- class User(Base, ComparableEntity):
+ class User(Base, fixtures.ComparableEntity):
__tablename__ = 'users'
id = Column('id', Integer, primary_key=True,
def test_column_properties(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,
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)
def test_deferred(self):
- class User(Base, ComparableEntity):
+ class User(Base, fixtures.ComparableEntity):
__tablename__ = 'users'
id = Column(Integer, primary_key=True,
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)
)
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)
def test_synonym_inline(self):
- class User(Base, ComparableEntity):
+ class User(Base, fixtures.ComparableEntity):
__tablename__ = 'users'
id = Column('id', Integer, primary_key=True,
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,
def test_synonym_added(self):
- class User(Base, ComparableEntity):
+ class User(Base, fixtures.ComparableEntity):
__tablename__ = 'users'
id = Column('id', Integer, primary_key=True,
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,
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,
def test_relationship_reference(self):
- class Address(Base, ComparableEntity):
+ class Address(Base, fixtures.ComparableEntity):
__tablename__ = 'addresses'
id = Column('id', Integer, primary_key=True,
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,
def test_synonym_for(self):
- class User(Base, ComparableEntity):
+ class User(Base, fixtures.ComparableEntity):
__tablename__ = 'users'
id = Column('id', Integer, primary_key=True,
):
return op(self.upperself, other, **kw)
- class User(Base, ComparableEntity):
+ class User(Base, fixtures.ComparableEntity):
__tablename__ = 'users'
id = Column('id', Integer, primary_key=True,
def test_joined(self):
- class Company(Base, ComparableEntity):
+ class Company(Base, fixtures.ComparableEntity):
__tablename__ = 'companies'
id = Column('id', Integer, primary_key=True,
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,
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,
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,
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,
def test_subclass_mixin(self):
- class Person(Base, ComparableEntity):
+ class Person(Base, fixtures.ComparableEntity):
__tablename__ = 'people'
id = Column('id', Integer, primary_key=True)
"""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,
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,
"""
- class Company(Base, ComparableEntity):
+ class Company(Base, fixtures.ComparableEntity):
__tablename__ = 'companies'
id = Column('id', Integer, primary_key=True,
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,
def test_joined_from_single(self):
- class Company(Base, ComparableEntity):
+ class Company(Base, fixtures.ComparableEntity):
__tablename__ = 'companies'
id = Column('id', Integer, primary_key=True,
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,
def test_add_deferred(self):
- class Person(Base, ComparableEntity):
+ class Person(Base, fixtures.ComparableEntity):
__tablename__ = 'people'
id = Column('id', Integer, primary_key=True,
"""
- class Person(Base, ComparableEntity):
+ class Person(Base, fixtures.ComparableEntity):
__tablename__ = 'people'
id = Column(Integer, primary_key=True,
ForeignKey('languages.id'))
primary_language = relationship('Language')
- class Language(Base, ComparableEntity):
+ class Language(Base, fixtures.ComparableEntity):
__tablename__ = 'languages'
id = Column(Integer, primary_key=True,
def test_single_three_levels(self):
- class Person(Base, ComparableEntity):
+ class Person(Base, fixtures.ComparableEntity):
__tablename__ = 'people'
id = Column(Integer, primary_key=True)
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)
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)
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}
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,
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,
exec '%s = testclass' % testclass.__name__
del testclass
-class DeclarativeReflectionTest(testing.TestBase):
+class DeclarativeReflectionTest(fixtures.TestBase):
@classmethod
def setup_class(cls):
def test_basic(self):
meta = MetaData(testing.db)
- class User(Base, ComparableEntity):
+ class User(Base, fixtures.ComparableEntity):
__tablename__ = 'users'
__autoload__ = True
test_needs_autoincrement=True)
addresses = relationship('Address', backref='user')
- class Address(Base, ComparableEntity):
+ class Address(Base, fixtures.ComparableEntity):
__tablename__ = 'addresses'
__autoload__ = True
def test_rekey(self):
meta = MetaData(testing.db)
- class User(Base, ComparableEntity):
+ class User(Base, fixtures.ComparableEntity):
__tablename__ = 'users'
__autoload__ = True
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
def test_supplied_fk(self):
meta = MetaData(testing.db)
- class IMHandle(Base, ComparableEntity):
+ class IMHandle(Base, fixtures.ComparableEntity):
__tablename__ = 'imhandles'
__autoload__ = True
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
# 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
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):
"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()
"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()
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()
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):
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()
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),
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()
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),
ClassManager.dispatch._clear()
super(_CompositeTestBase, self).teardown()
-class MutableCompositesTest(_CompositeTestBase, _base.MappedTest):
+class MutableCompositesTest(_CompositeTestBase, fixtures.MappedTest):
@classmethod
def _type_fixture(cls):
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
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'
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',
"""
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')
-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
# 'each', None
run_deletes = 'each'
- # 'once', 'each', None
+ # 'once', None
run_dispose_bind = None
bind = None
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):
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
+
"""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):
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,
+++ /dev/null
-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
-
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.
"""
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):
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
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
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
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):
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,
)
-class FalseDiscriminatorTest(_base.MappedTest):
+class FalseDiscriminatorTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
global t1
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
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):
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'
cls.tables.table_c,
cls.tables.table_a)
- class A(cls.Comparable):
+ class A(cls.Basic):
pass
class B(A):
pass
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."""
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={
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,
self.tables.related)
# test [ticket:1186]
- class Base(_base.BasicEntity):
+ class Base(fixtures.BasicEntity):
pass
class Sub(Base):
pass
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
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."""
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."""
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
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
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,
self.tables.base,
self.tables.stuff)
- class Base(_base.ComparableEntity):
+ class Base(fixtures.BasicEntity):
pass
class Sub(Base):
pass
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
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."""
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
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
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
""""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
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
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
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
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
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
self.tables.sub,
self.tables.subsub)
- class Base(_base.ComparableEntity):
+ class Base(fixtures.BasicEntity):
pass
class Sub(Base):
pass
),
)
-class NoPKOnSubTableWarningTest(testing.TestBase):
+class NoPKOnSubTableWarningTest(fixtures.TestBase):
def _fixture(self):
metadata = MetaData()
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,
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,
[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.
)
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')
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
pass
-class ConcreteTest(_base.MappedTest):
+class ConcreteTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
self.assert_sql_count(testing.db, go, 1)
-class PropertyInheritanceTest(_base.MappedTest):
+class PropertyInheritanceTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
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):
eq_(b1.related, [r1, r2])
-class ColKeysTest(_base.MappedTest):
+class ColKeysTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
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):
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, \
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):
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):
{'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):
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
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
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
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
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):
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):
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):
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
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
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):
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
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
)
def test_selfref_onjoined(self):
- class Taggable(_base.ComparableEntity):
+ class Taggable(fixtures.ComparableEntity):
pass
class User(Taggable):
[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
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
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
class_mapper(BaseItem)
-class CustomPKTest(_base.MappedTest):
+class CustomPKTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
global t1, t2
ot1.data = 'hi'
sess.flush()
-class InheritingEagerTest(_base.MappedTest):
+class InheritingEagerTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
global people, employees, tags, peopleTags
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
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
)
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
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):
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
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
del testclass
-class SelfReferentialTestJoinedToBase(_base.MappedTest):
+class SelfReferentialTestJoinedToBase(fixtures.MappedTest):
run_setup_mappers = 'once'
@classmethod
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
-class M2MFilterTest(_base.MappedTest):
+class M2MFilterTest(fixtures.MappedTest):
run_setup_mappers = 'once'
run_inserts = 'once'
run_deletes = None
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,
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'
)
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'
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
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
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,
self.tables.reports,
self.classes.Engineer)
- class Report(_base.ComparableEntity):
+ class Report(fixtures.ComparableEntity):
pass
mapper(Report, reports, properties={
self.tables.reports,
self.classes.Engineer)
- class Report(_base.ComparableEntity):
+ class Report(fixtures.ComparableEntity):
pass
mapper(Report, reports, properties={
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,
use_default_dialect=True
)
-class RelationshipToSingleTest(_base.MappedTest):
+class RelationshipToSingleTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
Table('employees', metadata,
)
go()
-class SingleOnJoinedTest(_base.MappedTest):
+class SingleOnJoinedTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
global persons_table, employees_table
)
def test_single_on_joined(self):
- class Person(_base.ComparableEntity):
+ class Person(fixtures.ComparableEntity):
pass
class Employee(Person):
pass
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'
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"
eq_(result, [u'3 Some Category'])
-class EagerTest2(_base.MappedTest):
+class EagerTest2(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
Table('left', metadata,
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
eq_(verify_result, arb_result)
-class EagerTest4(_base.MappedTest):
+class EagerTest4(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
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
assert len([c for c in d2.comments]) == 1
-class EagerTest6(_base.MappedTest):
+class EagerTest6(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
x.inheritedParts
-class EagerTest7(_base.MappedTest):
+class EagerTest7(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
Table('companies', metadata,
-class EagerTest8(_base.MappedTest):
+class EagerTest8(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
@classmethod
def setup_classes(cls):
- class Task_Type(cls.Basic):
+ class Task_Type(cls.Comparable):
pass
class Joined(cls.Comparable):
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
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
MyTest2 = None
-class AttributesTest(_base.ORMTest):
+class AttributesTest(fixtures.ORMTest):
def setup(self):
global MyTest, MyTest2
class MyTest(object): pass
"""
- class Foo(_base.ComparableEntity):
+ class Foo(fixtures.BasicEntity):
pass
- class Bar(_base.ComparableEntity):
+ class Bar(fixtures.BasicEntity):
pass
class ReceiveEvents(AttributeExtension):
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):
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)
except sa_exc.ArgumentError, e:
assert False
-class UtilTest(_base.ORMTest):
+class UtilTest(fixtures.ORMTest):
def test_helpers(self):
class Foo(object):
pass
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
# 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
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)
attributes.instance_dict(f)), 3)
def test_scalar(self):
- class Foo(_base.BasicEntity):
+ class Foo(fixtures.BasicEntity):
pass
instrumentation.register_class(Foo)
def test_mutable_scalar(self):
- class Foo(_base.BasicEntity):
+ class Foo(fixtures.BasicEntity):
pass
instrumentation.register_class(Foo)
'someattr'), ((), [{'foo': 'old'}], ()))
def test_flag_modified(self):
- class Foo(_base.BasicEntity):
+ class Foo(fixtures.BasicEntity):
pass
instrumentation.register_class(Foo)
'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
'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
'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
'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)
'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)
'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 = []
'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 = []
'bars'), ([bar2], [], []))
def test_scalar_via_lazyload(self):
- class Foo(_base.BasicEntity):
+ class Foo(fixtures.BasicEntity):
pass
lazy_load = None
'bar'), ([None], (), ['hi']))
def test_scalar_via_lazyload_with_active(self):
- class Foo(_base.BasicEntity):
+ class Foo(fixtures.BasicEntity):
pass
lazy_load = None
'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
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."""
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
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,
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
assert users.count().scalar() == 1
assert orders.count().scalar() == 0
-class O2MCascadeDeleteNoOrphanTest(_base.MappedTest):
+class O2MCascadeDeleteNoOrphanTest(fixtures.MappedTest):
run_inserts = None
@classmethod
assert k1 not in sess
-class M2OCascadeDeleteOrphanTestOne(_base.MappedTest):
+class M2OCascadeDeleteOrphanTestOne(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
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):
assert z.t3 is y
assert x.t3 is None
-class M2OCascadeDeleteNoOrphanTest(_base.MappedTest):
+class M2OCascadeDeleteNoOrphanTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
-class M2MCascadeTest(_base.MappedTest):
+class M2MCascadeTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
Table('a', metadata,
sess.commit
)
-class PendingOrphanTestSingleLevel(_base.MappedTest):
+class PendingOrphanTestSingleLevel(fixtures.MappedTest):
"""Pending entities that are orphans"""
@classmethod
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
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.).
"""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)
"""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)
'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).
"""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)
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)
session.add(a1)
session.flush()
-class CollectionAssignmentOrphanTest(_base.MappedTest):
+class CollectionAssignmentOrphanTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
Table('table_a', metadata,
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={
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.
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):
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={
"""test ticket 1306"""
- class Base(_base.ComparableEntity):
+ class Base(fixtures.ComparableEntity):
pass
class Parent(Base):
pass
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):
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
obj.attr[0] = e3
self.assert_(e3 in canary.data)
-class DictHelpersTest(_base.MappedTest):
+class DictHelpersTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
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
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):
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):
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,
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
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
e = Edge()
eq_(e.start, None)
-class PrimaryKeyTest(_base.MappedTest):
+class PrimaryKeyTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
Table('graphs', metadata,
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
def __ne__(self, other):
return not self.__eq__(other)
- class Graph(cls.Basic):
+ class Graph(cls.Comparable):
def __init__(self, version):
self.version = version
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):
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
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,
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)
[(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',
class B(cls.Comparable):
pass
- class C(cls.Basic):
+ class C(cls.Comparable):
def __init__(self, b1, b2):
self.b1, self.b2 = b1, b2
a2
)
-class ConfigurationTest(_base.MappedTest):
+class ConfigurationTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
Table('edge', metadata,
@classmethod
def setup_mappers(cls):
- class Point(cls.Basic):
+ class Point(cls.Comparable):
def __init__(self, x, y):
self.x = x
self.y = y
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
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
eq_(t.parent.uuid, t1.uuid)
-class InheritTestOne(_base.MappedTest):
+class InheritTestOne(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
Table("parent", metadata,
session.flush()
-class InheritTestTwo(_base.MappedTest):
+class InheritTestTwo(fixtures.MappedTest):
"""
The fix in BiDirectionalManyToOneTest raised this issue, regarding the
sess.flush()
-class BiDirectionalManyToOneTest(_base.MappedTest):
+class BiDirectionalManyToOneTest(fixtures.MappedTest):
run_define_tables = 'each'
@classmethod
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'
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"""
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
@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):
)
-class SelfReferentialPostUpdateTest(_base.MappedTest):
+class SelfReferentialPostUpdateTest(fixtures.MappedTest):
"""Post_update on a single self-referential mapper.
cats.prev_sibling = None
session.flush()
-class SelfReferentialPostUpdateTest2(_base.MappedTest):
+class SelfReferentialPostUpdateTest2(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
assert f2.foo is f1
-class SelfReferentialPostUpdateTest3(_base.MappedTest):
+class SelfReferentialPostUpdateTest3(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
Table('parent', metadata,
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
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
@classmethod
def setup_classes(cls):
- class Default(cls.Basic):
+ class Default(cls.Comparable):
pass
@classmethod
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,
def test_exclude(self):
dt = self.tables.dt
- class Foo(_base.ComparableEntity):
+ class Foo(fixtures.BasicEntity):
pass
mapper(Foo, dt, exclude_properties=('col1',))
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
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):
else:
self._comparator_factory = lambda mapper: None
-class DescriptorInstrumentationTest(_base.ORMTest):
+class DescriptorInstrumentationTest(fixtures.ORMTest):
def _fixture(self):
Base = declarative_base()
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):
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,
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
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,
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)
])
-class SelfReferentialEagerTest(_base.MappedTest):
+class SelfReferentialEagerTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
Table('nodes', metadata,
def test_basic(self):
nodes = self.tables.nodes
- class Node(_base.ComparableEntity):
+ class Node(fixtures.ComparableEntity):
def append(self, node):
self.children.append(node)
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)
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)
def test_options(self):
nodes = self.tables.nodes
- class Node(_base.ComparableEntity):
+ class Node(fixtures.ComparableEntity):
def append(self, node):
self.children.append(node)
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)
]), 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,
)
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,
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={
dialect=DefaultDialect()
)
-class CyclicalInheritingEagerTest(_base.MappedTest):
+class CyclicalInheritingEagerTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
# 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,
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
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
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)
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
testeval(an_obj, result)
return testeval
-class EvaluateTest(_base.MappedTest):
+class EvaluateTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
Table('users', metadata,
@classmethod
def setup_classes(cls):
- class User(cls.Comparable):
+ class User(cls.Basic):
pass
@classmethod
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
assert len(m.dispatch.before_insert) == 1
-class AttributeExtensionTest(_base.MappedTest):
+class AttributeExtensionTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
Table('t1',
ext_msg.append("Ex2 %r" % value)
return "ex2" + value
- class A(_base.BasicEntity):
+ class A(fixtures.BasicEntity):
pass
class B(A):
pass
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):
-class PolymorphicExpireTest(_base.MappedTest):
+class PolymorphicExpireTest(fixtures.MappedTest):
run_inserts = 'once'
run_deletes = None
@classmethod
def setup_classes(cls):
- class Person(cls.Comparable):
+ class Person(cls.Basic):
pass
class Engineer(Person):
pass
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):
else:
del self._goofy_dict[key]
-class UserDefinedExtensionTest(_base.ORMTest):
+class UserDefinedExtensionTest(fixtures.ORMTest):
@classmethod
def teardown_class(cls):
clear_mappers()
from test.orm import _fixtures
-from test.orm import _base
+from test.lib import fixtures
from sqlalchemy.orm.util import join, outerjoin, with_parent
)
-class AddEntityEquivalenceTest(_base.MappedTest, AssertsCompiledSQL):
+class AddEntityEquivalenceTest(fixtures.MappedTest, AssertsCompiledSQL):
run_setup_mappers = 'once'
@classmethod
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,
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={
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
assert len(list(query.limit(10))) == 10
-class GenerativeTest2(_base.MappedTest):
+class GenerativeTest2(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
set(q.all()))
-class CaseSensitiveTest(_base.MappedTest):
+class CaseSensitiveTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
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):
return decorate
-class InitTest(_base.ORMTest):
+class InitTest(fixtures.ORMTest):
def fixture(self):
return Table('t', MetaData(),
Column('id', Integer, primary_key=True),
assert o.o is Y.outofscope
-class MapperInitTest(_base.ORMTest):
+class MapperInitTest(fixtures.ORMTest):
def fixture(self):
return Table('t', MetaData(),
# 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)
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):
instrumentation._install_lookup_strategy(util.symbol('native'))
-class ExtendedEventsTest(_base.ORMTest):
+class ExtendedEventsTest(fixtures.ORMTest):
"""Allow custom Events implementations."""
@modifies_instrumentation_finders
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
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):
assert b in session, 'base: %s' % base
-class FinderTest(_base.ORMTest):
+class FinderTest(fixtures.ORMTest):
def test_standard(self):
class A(object): pass
from test.orm import _fixtures
-from test.orm import _base
+from test.lib import fixtures
from sqlalchemy.orm.util import join, outerjoin, with_parent
configure_mappers()
-class InheritedJoinTest(_base.MappedTest, AssertsCompiledSQL):
+class InheritedJoinTest(fixtures.MappedTest, AssertsCompiledSQL):
run_setup_mappers = 'once'
@classmethod
)
-class MultiplePathTest(_base.MappedTest, AssertsCompiledSQL):
+class MultiplePathTest(fixtures.MappedTest, AssertsCompiledSQL):
@classmethod
def define_tables(cls, metadata):
t1 = Table('t1', metadata,
)
-class SelfRefMixedTest(_base.MappedTest, AssertsCompiledSQL):
+class SelfRefMixedTest(fixtures.MappedTest, AssertsCompiledSQL):
run_setup_mappers = 'once'
__dialect__ = default.DefaultDialect()
)
-class SelfReferentialTest(_base.MappedTest, AssertsCompiledSQL):
+class SelfReferentialTest(fixtures.MappedTest, AssertsCompiledSQL):
run_setup_mappers = 'once'
run_inserts = 'once'
run_deletes = None
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
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):
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):
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)
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):
self.sql_count_(1, go)
-class PickledDictsTest(_base.MappedTest):
+class PickledDictsTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
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
engine = testing.db
-class FlushOnPendingTest(AssertsExecutionResults, TestBase):
+class FlushOnPendingTest(AssertsExecutionResults, fixtures.TestBase):
def setUp(self):
global Parent, Child, Base
Base= declarative_base()
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
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,
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,
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,
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,
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')
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'),
sess.commit
)
-class M2MTest2(_base.MappedTest):
+class M2MTest2(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
Table('student', metadata,
sess.flush()
assert enroll.count().scalar() == 0
-class M2MTest3(_base.MappedTest):
+class M2MTest3(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
Table('c', metadata,
# 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,
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={
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):
assert_col = []
- class User(_base.ComparableEntity):
+ class User(fixtures.ComparableEntity):
def _get_name(self):
assert_col.append(('get', self._name))
return self._name
mapper(B, users)
-class DocumentTest(testing.TestBase):
+class DocumentTest(fixtures.TestBase):
def test_doc_propagate(self):
metadata = MetaData()
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'
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
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'
)
-class DeferredPopulationTest(_base.MappedTest):
+class DeferredPopulationTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
Table("thing", metadata,
-class RequirementsTest(_base.MappedTest):
+class RequirementsTest(fixtures.MappedTest):
"""Tests the contract for user classes."""
@classmethod
h2.value = "Asdf"
h2.value = "asdf asdf" # ding
-class MagicNamesTest(_base.MappedTest):
+class MagicNamesTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
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
eq_(ustate.load_options, set([opt2]))
-class MutableMergeTest(_base.MappedTest):
+class MutableMergeTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
Table("data", metadata,
@classmethod
def setup_classes(cls):
- class Data(cls.Comparable):
+ class Data(cls.Basic):
pass
def test_list(self):
-class CompositeNullPksTest(_base.MappedTest):
+class CompositeNullPksTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
Table("data", metadata,
@classmethod
def setup_classes(cls):
- class Data(cls.Comparable):
+ class Data(cls.Basic):
pass
def test_merge_allow_partial(self):
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):
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."""
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')
Node.name.in_(['n11', 'n12', 'n13']))])
-class NonPKCascadeTest(_base.MappedTest):
+class NonPKCascadeTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
if testing.against('oracle'):
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."""
[('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
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,
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,
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,
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,
from test.orm import _fixtures
-from test.orm import _base
+from test.lib import fixtures
from sqlalchemy.orm.util import join, outerjoin, with_parent
s = users.outerjoin(addresses)
- class UserThing(_base.ComparableEntity):
+ class UserThing(fixtures.ComparableEntity):
pass
mapper(UserThing, s, properties={
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,
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})
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'
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.
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,
s.delete(j)
s.flush()
-class FKsAsPksTest(_base.MappedTest):
+class FKsAsPksTest(fixtures.MappedTest):
"""Syncrules on foreign keys that are also primary"""
@classmethod
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")
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"""
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
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(
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.
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={
[TagInstance(data='iplc_case'), TagInstance(data='not_iplc_case')]
)
-class BackrefPropagatesForwardsArgs(_base.MappedTest):
+class BackrefPropagatesForwardsArgs(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
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.
"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
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"""
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)
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)
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)
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")})
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)})
"doesn't handle objects of type",
sess.add, d1)
-class TypedAssociationTable(_base.MappedTest):
+class TypedAssociationTable(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
"""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')})
assert t3.count().scalar() == 1
-class ViewOnlyM2MBackrefTest(_base.MappedTest):
+class ViewOnlyM2MBackrefTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
Table("t1", metadata,
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,
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
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),
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
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),
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):
-class ViewOnlyNonEquijoin(_base.MappedTest):
+class ViewOnlyNonEquijoin(fixtures.MappedTest):
"""'viewonly' mappings based on non-equijoins."""
@classmethod
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={
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
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={
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
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={
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
sa.orm.configure_mappers)
-class ExplicitLocalRemoteTest(_base.MappedTest):
+class ExplicitLocalRemoteTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
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,
configure_mappers)
-class InvalidRelationshipEscalationTest(_base.MappedTest):
+class InvalidRelationshipEscalationTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
configure_mappers)
-class InvalidRelationshipEscalationTestM2M(_base.MappedTest):
+class InvalidRelationshipEscalationTestM2M(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
-class RelationDeprecationTest(_base.MappedTest):
+class RelationDeprecationTest(fixtures.MappedTest):
"""test usage of the old 'relation' function."""
run_inserts = 'once'
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):
super(_ScopedTest, cls).teardown_class()
-class ScopedSessionTest(_base.MappedTest):
+class ScopedSessionTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
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)
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,
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
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
sess.rollback()
-class SessionInterface(testing.TestBase):
+class SessionInterface(fixtures.TestBase):
"""Bogus args to Session methods produce actionable exceptions."""
# TODO: expand with message body assertions.
self._test_class_guards(early)
-class TLTransactionTest(_base.MappedTest):
+class TLTransactionTest(fixtures.MappedTest):
run_dispose_bind = 'once'
@classmethod
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):
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,
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)
])
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,
def test_basic(self):
nodes = self.tables.nodes
- class Node(_base.ComparableEntity):
+ class Node(fixtures.ComparableEntity):
def append(self, node):
self.children.append(node)
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)
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)
def test_options(self):
nodes = self.tables.nodes
- class Node(_base.ComparableEntity):
+ class Node(fixtures.ComparableEntity):
def append(self, node):
self.children.append(node)
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)
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):
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,
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
assert u.addresses[0].user == u
session.close()
-class UnicodeTest(_base.MappedTest):
+class UnicodeTest(fixtures.MappedTest):
__requires__ = ('unicode_connections',)
@classmethod
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'
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={
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
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,
-class PKTest(_base.MappedTest):
+class PKTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
session.flush()
-class ForeignPKTest(_base.MappedTest):
+class ForeignPKTest(fixtures.MappedTest):
"""Detection of the relationship direction on PK joins."""
@classmethod
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):
assert (u.counter == 5) is True
-class PassiveDeletesTest(_base.MappedTest):
+class PassiveDeletesTest(fixtures.MappedTest):
__requires__ = ('foreign_keys',)
@classmethod
mapper(MyClass, mytable)
assert_raises(sa.exc.SAWarning, sa.orm.configure_mappers)
-class ExtraPassiveDeletesTest(_base.MappedTest):
+class ExtraPassiveDeletesTest(fixtures.MappedTest):
__requires__ = ('foreign_keys',)
@classmethod
# 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
def test_naming(self):
book = self.tables.book
- class Book(_base.ComparableEntity):
+ class Book(fixtures.ComparableEntity):
pass
mapper(Book, book)
-class DefaultTest(_base.MappedTest):
+class DefaultTest(fixtures.MappedTest):
"""Exercise mappings on columns with DefaultGenerators.
Tests that when saving objects whose table contains DefaultGenerators,
Secondary(data='s1'),
Secondary(data='s2')]))
-class ColumnPropertyTest(_base.MappedTest):
+class ColumnPropertyTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
Table('data', metadata,
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):
"""Basic test of an association object"""
- class IKAssociation(_base.ComparableEntity):
+ class IKAssociation(fixtures.ComparableEntity):
pass
mapper(Keyword, keywords)
{'user_id': 2, 'email_address': 'a2'}),
)
-class SaveTest3(_base.MappedTest):
+class SaveTest3(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
Table('items', metadata,
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,
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)
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
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.
-class RowSwitchTest(_base.MappedTest):
+class RowSwitchTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
# parent
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,
-class TransactionTest(_base.MappedTest):
+class TransactionTest(fixtures.MappedTest):
__requires__ = ('deferrable_constraints',)
__whitelist__ = ('sqlite',)
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
-class SingleCyclePlusAttributeTest(_base.MappedTest,
+class SingleCyclePlusAttributeTest(fixtures.MappedTest,
testing.AssertsExecutionResults, AssertsUOW):
@classmethod
def define_tables(cls, metadata):
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={
sess.flush()
-class SingleCycleM2MTest(_base.MappedTest,
+class SingleCycleM2MTest(fixtures.MappedTest,
testing.AssertsExecutionResults, AssertsUOW):
@classmethod
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={
),
)
-class RowswitchAccountingTest(_base.MappedTest):
+class RowswitchAccountingTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
Table('parent', metadata,
sess.flush()
-class BatchInsertsTest(_base.MappedTest, testing.AssertsExecutionResults):
+class BatchInsertsTest(fixtures.MappedTest, testing.AssertsExecutionResults):
@classmethod
def define_tables(cls, metadata):
Table('t', metadata,
key present statements together.
"""
- class T(_base.ComparableEntity):
+ class T(fixtures.ComparableEntity):
pass
mapper(T, t)
sess = Session()
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),
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 = [
"""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):
@classmethod
def setup_classes(cls):
- class Foo(cls.Comparable):
+ class Foo(cls.Basic):
pass
def _fixture(self):
s1.merge, f2
)
-class RowSwitchTest(_base.MappedTest):
+class RowSwitchTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):
Table('p', metadata,
@classmethod
def setup_classes(cls):
- class P(cls.Comparable):
+ class P(cls.Basic):
pass
- class C(cls.Comparable):
+ class C(cls.Basic):
pass
@classmethod
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,
@classmethod
def setup_classes(cls):
- class P(cls.Comparable):
+ class P(cls.Basic):
pass
- class C(cls.Comparable):
+ class C(cls.Basic):
pass
@classmethod
)
-class InheritanceTwoVersionIdsTest(_base.MappedTest):
+class InheritanceTwoVersionIdsTest(fixtures.MappedTest):
"""Test versioning where both parent/child table have a
versioning column.
@classmethod
def setup_classes(cls):
- class Base(cls.Comparable):
+ class Base(cls.Basic):
pass
class Sub(Base):
pass
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
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={
+++ /dev/null
-from test.engine import _base as engine_base
-
-
-TablesTest = engine_base.TablesTest
from sqlalchemy.sql import table, column
-class CaseTest(TestBase, AssertsCompiledSQL):
+class CaseTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = 'default'
@classmethod
column('zip')
)
-class SelectTest(TestBase, AssertsCompiledSQL):
+class SelectTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = 'default'
def test_attribute_sanity(self):
)
-class CRUDTest(TestBase, AssertsCompiledSQL):
+class CRUDTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = 'default'
def test_insert(self):
"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):
"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):
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
Index('bar', t1.c.x)
)
-class ConstraintCompilationTest(TestBase, AssertsCompiledSQL):
+class ConstraintCompilationTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = 'default'
def _test_deferrable(self, constraint_factory):
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):
eq_(55, l['col3'])
-class PKDefaultTest(_base.TablesTest):
+class PKDefaultTest(fixtures.TablesTest):
__requires__ = ('subqueries',)
@classmethod
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
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):
finally:
metadata.drop_all()
-class AutoIncrementTest(_base.TablesTest):
+class AutoIncrementTest(fixtures.TablesTest):
__requires__ = ('identity',)
run_define_tables = 'each'
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):
"DROP SEQUENCE foo_seq",
)
-class SequenceExecTest(testing.TestBase):
+class SequenceExecTest(fixtures.TestBase):
__requires__ = ('sequences',)
@classmethod
)
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')
assert not self._has_sequence('s2')
-class TableBoundSequenceTest(testing.TestBase):
+class TableBoundSequenceTest(fixtures.TestBase):
__requires__ = ('sequences',)
@classmethod
(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,
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
[(5, 'data')]
)
-class UnicodeDefaultsTest(testing.TestBase):
+class UnicodeDefaultsTest(fixtures.TestBase):
def test_no_default(self):
c = Column(Unicode(32))
from sqlalchemy.databases import *
-class CompileTest(TestBase, AssertsCompiledSQL):
+class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = 'default'
def test_compile(self):
, 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
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."""
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'
':col1_1) AS anon_1 WHERE table1.col1 = '
'anon_1.col1')
-class ClauseAdapterTest(TestBase, AssertsCompiledSQL):
+class ClauseAdapterTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = 'default'
@classmethod
"WHERE c.bid = anon_1.b_aid"
)
-class SpliceJoinsTest(TestBase, AssertsCompiledSQL):
+class SpliceJoinsTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = 'default'
@classmethod
'table1.col3 = table4_1.col3')
-class SelectTest(TestBase, AssertsCompiledSQL):
+class SelectTest(fixtures.TestBase, AssertsCompiledSQL):
"""tests the generative capability of Select"""
__dialect__ = 'default'
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'
IDENT_LENGTH = 29
-class LabelTypeTest(TestBase):
+class LabelTypeTest(fixtures.TestBase):
def test_type(self):
m = MetaData()
t = Table('sometable', m,
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
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,
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),
assign
)
-class ConstraintTest(TestBase):
+class ConstraintTest(fixtures.TestBase):
def _single_fixture(self):
m = MetaData()
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'
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')
assert c.info['bar'] == 'zip'
-class CatchAllEventsTest(TestBase):
+class CatchAllEventsTest(fixtures.TestBase):
def teardown(self):
events.SchemaEventTarget.dispatch._clear()
from test.lib import *
from test.lib.schema import Table, Column
-class QueryTest(TestBase):
+class QueryTest(fixtures.TestBase):
@classmethod
def setup_class(cls):
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
-class LimitTest(TestBase):
+class LimitTest(fixtures.TestBase):
@classmethod
def setup_class(cls):
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
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
self.assertRows(expr, [(10, 20, 30)])
-class OperatorTest(TestBase):
+class OperatorTest(fixtures.TestBase):
@classmethod
def setup_class(cls):
global metadata, flds
from sqlalchemy.sql import compiler
from test.lib import *
-class QuoteTest(TestBase, AssertsCompiledSQL):
+class QuoteTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = 'default'
@classmethod
'''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):
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):
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):
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',
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
from test.lib import *
-class FoundRowsTest(TestBase, AssertsExecutionResults):
+class FoundRowsTest(fixtures.TestBase, AssertsExecutionResults):
"""tests rowcount functionality"""
__requires__ = ('sane_rowcount', )
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,
)
-class SelectableTest(TestBase, AssertsExecutionResults):
+class SelectableTest(fixtures.TestBase, AssertsExecutionResults):
def test_indirect_correspondence_on_labels(self):
# this test depends upon 'distance' to
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
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,
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()
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):
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)
typ, 11
)
-class TypeAffinityTest(TestBase):
+class TypeAffinityTest(fixtures.TestBase):
def test_type_affinity(self):
for type_, affin in [
(String(), String),
]:
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 = [
mt = loads(dumps(meta))
-class UserDefinedTest(_base.TablesTest, AssertsCompiledSQL):
+class UserDefinedTest(fixtures.TablesTest, AssertsCompiledSQL):
"""tests user-defined types."""
def test_processing(self):
)
-class UnicodeTest(TestBase, AssertsExecutionResults):
+class UnicodeTest(fixtures.TestBase, AssertsExecutionResults):
"""tests the Unicode type. also tests the TypeDecorator with instances in the types package."""
@classmethod
m.drop_all(engine)
-class EnumTest(TestBase):
+class EnumTest(fixtures.TestBase):
@classmethod
def setup_class(cls):
global enum_table, non_native_enum_table, metadata
{'id':4, 'someenum':'four'}
)
-class BinaryTest(TestBase, AssertsExecutionResults):
+class BinaryTest(fixtures.TestBase, AssertsExecutionResults):
__excluded_on__ = (
('mysql', '<', (4, 1, 1)), # screwy varbinary types
)
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
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.
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
finally:
t.drop(checkfirst=True)
-class StringTest(TestBase):
+class StringTest(fixtures.TestBase):
@testing.requires.unbounded_varchar
def test_nolength_string(self):
foo.create()
foo.drop()
-class NumericTest(TestBase):
+class NumericTest(fixtures.TestBase):
def setup(self):
global metadata
metadata = MetaData(testing.db)
numbers
)
-class NumericRawSQLTest(TestBase):
+class NumericRawSQLTest(fixtures.TestBase):
"""Test what DBAPIs and dialects return without any typing
information supplied at the SQLA level.
-class IntervalTest(TestBase, AssertsExecutionResults):
+class IntervalTest(fixtures.TestBase, AssertsExecutionResults):
@classmethod
def setup_class(cls):
global interval_table, metadata
eq_(row['non_native_interval'], None)
-class BooleanTest(TestBase, AssertsExecutionResults):
+class BooleanTest(fixtures.TestBase, AssertsExecutionResults):
@classmethod
def setup_class(cls):
global bool_table
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()
):
assert p1.compare_values(p1.copy_value(obj), obj)
-class CallableTest(TestBase):
+class CallableTest(fixtures.TestBase):
@classmethod
def setup_class(cls):
global meta
"""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
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,