From: Mike Bayer Date: Sat, 20 Nov 2010 16:35:16 +0000 (-0500) Subject: - repair remaining tests X-Git-Tag: rel_0_7b1~253^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61c76f92df7c0b5b1ce0178148bab71bc4a64ec7;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - repair remaining tests --- diff --git a/test/aaa_profiling/test_orm.py b/test/aaa_profiling/test_orm.py index 4f94be79c9..d7e7b8c000 100644 --- a/test/aaa_profiling/test_orm.py +++ b/test/aaa_profiling/test_orm.py @@ -53,7 +53,7 @@ class MergeTest(_base.MappedTest): # down from 185 on this this is a small slice of a usually # bigger operation so using a small variance - @profiling.function_call_count(93, variance=0.001, + @profiling.function_call_count(97, variance=0.001, versions={'2.4': 67, '3': 96}) def go(): return sess2.merge(p1, load=False) diff --git a/test/aaa_profiling/test_pool.py b/test/aaa_profiling/test_pool.py index f99af50656..b34144feb0 100644 --- a/test/aaa_profiling/test_pool.py +++ b/test/aaa_profiling/test_pool.py @@ -40,7 +40,7 @@ class QueuePoolTest(TestBase, AssertsExecutionResults): def test_second_samethread_connect(self): conn = pool.connect() - @profiling.function_call_count(5, {'2.4': 3, '3.0':6, '3.1':6}) + @profiling.function_call_count(6, {'2.4': 4, '3.0':7, '3.1':7}) def go(): return pool.connect() c2 = go() diff --git a/test/ext/test_declarative.py b/test/ext/test_declarative.py index 7c8ab0016f..fe22a51fae 100644 --- a/test/ext/test_declarative.py +++ b/test/ext/test_declarative.py @@ -568,50 +568,36 @@ class DeclarativeTest(DeclarativeTestBase): eq_(sess.query(User).all(), [User(name='u1', addresses=[Address(email='one'), Address(email='two')])]) - @testing.uses_deprecated() - def test_custom_mapper(self): - - class MyExt(sa.orm.MapperExtension): - - def create_instance(self): - return 'CHECK' + def test_custom_mapper_attribute(self): def mymapper(cls, tbl, **kwargs): - kwargs['extension'] = MyExt() - return sa.orm.mapper(cls, tbl, **kwargs) - - from sqlalchemy.orm.mapper import Mapper - - class MyMapper(Mapper): + m = sa.orm.mapper(cls, tbl, **kwargs) + m.CHECK = True + return m - def __init__(self, *args, **kwargs): - kwargs['extension'] = MyExt() - Mapper.__init__(self, *args, **kwargs) + base = decl.declarative_base() - from sqlalchemy.orm import scoping - ss = scoping.ScopedSession(create_session) - ss.extension = MyExt() - ss_mapper = ss.mapper - for mapperfunc in mymapper, MyMapper, ss_mapper: - base = decl.declarative_base() + class Foo(base): + __tablename__ = 'foo' + __mapper_cls__ = mymapper + id = Column(Integer, primary_key=True) + + eq_(Foo.__mapper__.CHECK, True) - class Foo(base): + def test_custom_mapper_argument(self): - __tablename__ = 'foo' - __mapper_cls__ = mapperfunc - id = Column(Integer, primary_key=True) - - eq_(Foo.__mapper__.compile().extension.create_instance(), - 'CHECK') - base = decl.declarative_base(mapper=mapperfunc) + def mymapper(cls, tbl, **kwargs): + m = sa.orm.mapper(cls, tbl, **kwargs) + m.CHECK = True + return m - class Foo(base): + base = decl.declarative_base(mapper=mymapper) - __tablename__ = 'foo' - id = Column(Integer, primary_key=True) + class Foo(base): + __tablename__ = 'foo' + id = Column(Integer, primary_key=True) - eq_(Foo.__mapper__.compile().extension.create_instance(), - 'CHECK') + eq_(Foo.__mapper__.CHECK, True) @testing.emits_warning('Ignoring declarative-like tuple value of ' 'attribute id') diff --git a/test/orm/test_cascade.py b/test/orm/test_cascade.py index 75b9e22ec1..f7a22dad68 100644 --- a/test/orm/test_cascade.py +++ b/test/orm/test_cascade.py @@ -446,7 +446,7 @@ class M2OCascadeTest(_base.MappedTest): # the error condition relies upon # these things being true - assert User.foo.impl.active_history is False + assert User.foo.dispatch.active_history is False eq_( attributes.get_history(u1, 'foo'), ([None], (), [attributes.PASSIVE_NO_RESULT])