[Sqlalchemy-commits] [6019] sqlalchemy/branches/rel_0_6: merged -r5991:6018 of trunk, primarily rem
Brought to you by:
zzzeek
From: <co...@sq...> - 2009-06-02 21:54:00
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!-- #msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; } #msg dt { float: left; width: 6em; font-weight: bold; } #msg dt:after { content:':';} #msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; } #msg dl a { font-weight: bold} #msg dl a:link { color:#fc3; } #msg dl a:active { color:#ff0; } #msg dl a:visited { color:#cc6; } h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; } #msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; } #msg ul, pre { overflow: auto; } #header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; } #patch { width: 100%; } #patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;} #patch .propset h4, #patch .binary h4 {margin:0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;} #patch .propset .diff, #patch .binary .diff {padding:10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, .info {color:#888;background:#fff;} --></style> <title>[6019] sqlalchemy/branches/rel_0_6: merged -r5991:6018 of trunk, primarily removal of testing.ORMTest and fixtures.py</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>6019</dd> <dt>Author</dt> <dd>zzzeek</dd> <dt>Date</dt> <dd>2009-06-02 17:53:52 -0400 (Tue, 02 Jun 2009)</dd> </dl> <h3>Log Message</h3> <pre>merged -r5991:6018 of trunk, primarily removal of testing.ORMTest and fixtures.py</pre> <h3>Modified Paths</h3> <ul> <li><a href="#sqlalchemybranchesrel_0_6CHANGES">sqlalchemy/branches/rel_0_6/CHANGES</a></li> <li><a href="#sqlalchemybranchesrel_0_6libsqlalchemyormstatepy">sqlalchemy/branches/rel_0_6/lib/sqlalchemy/orm/state.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6libsqlalchemyutilpy">sqlalchemy/branches/rel_0_6/lib/sqlalchemy/util.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testbasedependencypy">sqlalchemy/branches/rel_0_6/test/base/dependency.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testextdeclarativepy">sqlalchemy/branches/rel_0_6/test/ext/declarative.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testextserializerpy">sqlalchemy/branches/rel_0_6/test/ext/serializer.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testorm_basepy">sqlalchemy/branches/rel_0_6/test/orm/_base.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testormattributespy">sqlalchemy/branches/rel_0_6/test/orm/attributes.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testorminheritanceabc_inheritancepy">sqlalchemy/branches/rel_0_6/test/orm/inheritance/abc_inheritance.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testorminheritanceabc_polymorphicpy">sqlalchemy/branches/rel_0_6/test/orm/inheritance/abc_polymorphic.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testorminheritancebasicpy">sqlalchemy/branches/rel_0_6/test/orm/inheritance/basic.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testorminheritancemagazinepy">sqlalchemy/branches/rel_0_6/test/orm/inheritance/magazine.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testorminheritancemanytomanypy">sqlalchemy/branches/rel_0_6/test/orm/inheritance/manytomany.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testorminheritancepoly_linked_listpy">sqlalchemy/branches/rel_0_6/test/orm/inheritance/poly_linked_list.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testorminheritancepolymorphpy">sqlalchemy/branches/rel_0_6/test/orm/inheritance/polymorph.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testorminheritancepolymorph2py">sqlalchemy/branches/rel_0_6/test/orm/inheritance/polymorph2.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testorminheritanceproductspecpy">sqlalchemy/branches/rel_0_6/test/orm/inheritance/productspec.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testorminheritancequerypy">sqlalchemy/branches/rel_0_6/test/orm/inheritance/query.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testorminheritanceselectspy">sqlalchemy/branches/rel_0_6/test/orm/inheritance/selects.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testorminheritancesinglepy">sqlalchemy/branches/rel_0_6/test/orm/inheritance/single.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testormquerypy">sqlalchemy/branches/rel_0_6/test/orm/query.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testormsessionpy">sqlalchemy/branches/rel_0_6/test/orm/session.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testormtransactionpy">sqlalchemy/branches/rel_0_6/test/orm/transaction.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testormutilspy">sqlalchemy/branches/rel_0_6/test/orm/utils.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testperfsessionspy">sqlalchemy/branches/rel_0_6/test/perf/sessions.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testtestlib__init__py">sqlalchemy/branches/rel_0_6/test/testlib/__init__.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testtestlibormpy">sqlalchemy/branches/rel_0_6/test/testlib/orm.py</a></li> <li><a href="#sqlalchemybranchesrel_0_6testtestlibtestingpy">sqlalchemy/branches/rel_0_6/test/testlib/testing.py</a></li> </ul> <h3>Removed Paths</h3> <ul> <li><a href="#sqlalchemybranchesrel_0_6testtestlibfixturespy">sqlalchemy/branches/rel_0_6/test/testlib/fixtures.py</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="sqlalchemybranchesrel_0_6CHANGES"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/rel_0_6/CHANGES (6018 => 6019)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/rel_0_6/CHANGES 2009-06-02 21:42:14 UTC (rev 6018) +++ sqlalchemy/branches/rel_0_6/CHANGES 2009-06-02 21:53:52 UTC (rev 6019) </span><span class="lines">@@ -4,11 +4,15 @@ </span><span class="cx"> CHANGES </span><span class="cx"> ======= </span><span class="cx"> </span><del>-0.5.4p3 </del><ins>+0.5.5 </ins><span class="cx"> ======= </span><span class="cx"> - orm </span><span class="cx"> - Fixed bug introduced in 0.5.4 whereby Composite types </span><span class="cx"> fail when default-holding columns are flushed. </span><ins>+ + - Fixed another 0.5.4 bug whereby mutable attributes (i.e. PickleType) + wouldn't be deserialized correctly when the whole object + was serialized. [ticket:1426] </ins><span class="cx"> </span><span class="cx"> - sql </span><span class="cx"> - Removed an obscure feature of execute() (including connection, </span></span></pre></div> <a id="sqlalchemybranchesrel_0_6libsqlalchemyormstatepy"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/rel_0_6/lib/sqlalchemy/orm/state.py (6018 => 6019)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/rel_0_6/lib/sqlalchemy/orm/state.py 2009-06-02 21:42:14 UTC (rev 6018) +++ sqlalchemy/branches/rel_0_6/lib/sqlalchemy/orm/state.py 2009-06-02 21:53:52 UTC (rev 6019) </span><span class="lines">@@ -130,7 +130,8 @@ </span><span class="cx"> 'load_path':interfaces.serialize_path(self.load_path), </span><span class="cx"> 'instance': self.obj(), </span><span class="cx"> 'expired_attributes':self.expired_attributes, </span><del>- 'callables': self.callables} </del><ins>+ 'callables': self.callables, + 'mutable_dict':self.mutable_dict} </ins><span class="cx"> </span><span class="cx"> def __setstate__(self, state): </span><span class="cx"> self.committed_state = state['committed_state'] </span><span class="lines">@@ -148,6 +149,7 @@ </span><span class="cx"> self.runid = None </span><span class="cx"> self.expired = state['expired'] </span><span class="cx"> self.expired_attributes = state['expired_attributes'] </span><ins>+ self.mutable_dict = state['mutable_dict'] </ins><span class="cx"> </span><span class="cx"> def initialize(self, key): </span><span class="cx"> self.manager.get_impl(key).initialize(self, self.dict) </span></span></pre></div> <a id="sqlalchemybranchesrel_0_6libsqlalchemyutilpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/rel_0_6/lib/sqlalchemy/util.py (6018 => 6019)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/rel_0_6/lib/sqlalchemy/util.py 2009-06-02 21:42:14 UTC (rev 6018) +++ sqlalchemy/branches/rel_0_6/lib/sqlalchemy/util.py 2009-06-02 21:53:52 UTC (rev 6019) </span><span class="lines">@@ -13,7 +13,7 @@ </span><span class="cx"> from sqlalchemy import exc </span><span class="cx"> </span><span class="cx"> try: </span><del>- import threading as threading </del><ins>+ import threading </ins><span class="cx"> except ImportError: </span><span class="cx"> import dummy_threading as threading </span><span class="cx"> </span></span></pre></div> <a id="sqlalchemybranchesrel_0_6testbasedependencypy"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/rel_0_6/test/base/dependency.py (6018 => 6019)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/rel_0_6/test/base/dependency.py 2009-06-02 21:42:14 UTC (rev 6018) +++ sqlalchemy/branches/rel_0_6/test/base/dependency.py 2009-06-02 21:53:52 UTC (rev 6019) </span><span class="lines">@@ -174,7 +174,7 @@ </span><span class="cx"> question, issue, providerservice, answer, provider = "Question", "Issue", "ProviderService", "Answer", "Provider" </span><span class="cx"> </span><span class="cx"> tuples = [(question, issue), (providerservice, issue), (provider, question), (question, provider), (providerservice, question), (provider, providerservice), (question, answer), (issue, question)] </span><del>- </del><ins>+ </ins><span class="cx"> head = topological.sort_as_tree(tuples, [], with_cycles=True) </span><span class="cx"> self.assert_sort(tuples, head) </span><span class="cx"> </span></span></pre></div> <a id="sqlalchemybranchesrel_0_6testextdeclarativepy"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/rel_0_6/test/ext/declarative.py (6018 => 6019)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/rel_0_6/test/ext/declarative.py 2009-06-02 21:42:14 UTC (rev 6018) +++ sqlalchemy/branches/rel_0_6/test/ext/declarative.py 2009-06-02 21:53:52 UTC (rev 6019) </span><span class="lines">@@ -6,6 +6,8 @@ </span><span class="cx"> from testlib.sa import MetaData, Table, Column, Integer, String, ForeignKey, ForeignKeyConstraint, asc, Index </span><span class="cx"> from testlib.sa.orm import relation, create_session, class_mapper, eagerload, compile_mappers, backref, clear_mappers, polymorphic_union, deferred </span><span class="cx"> from testlib.testing import eq_ </span><ins>+ + </ins><span class="cx"> from orm._base import ComparableEntity, MappedTest </span><span class="cx"> </span><span class="cx"> class DeclarativeTestBase(testing.TestBase, testing.AssertsExecutionResults): </span><span class="lines">@@ -1269,7 +1271,7 @@ </span><span class="cx"> </span><span class="cx"> </span><span class="cx"> def produce_test(inline, stringbased): </span><del>- class ExplicitJoinTest(testing.ORMTest): </del><ins>+ class ExplicitJoinTest(MappedTest): </ins><span class="cx"> </span><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global User, Address </span></span></pre></div> <a id="sqlalchemybranchesrel_0_6testextserializerpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/rel_0_6/test/ext/serializer.py (6018 => 6019)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/rel_0_6/test/ext/serializer.py 2009-06-02 21:42:14 UTC (rev 6018) +++ sqlalchemy/branches/rel_0_6/test/ext/serializer.py 2009-06-02 21:53:52 UTC (rev 6019) </span><span class="lines">@@ -6,6 +6,7 @@ </span><span class="cx"> from testlib.sa import MetaData, Table, Column, Integer, String, ForeignKey, select, desc, func, util </span><span class="cx"> from testlib.sa.orm import relation, sessionmaker, scoped_session, class_mapper, mapper, eagerload, compile_mappers, aliased </span><span class="cx"> from testlib.testing import eq_ </span><ins>+ </ins><span class="cx"> from orm._base import ComparableEntity, MappedTest </span><span class="cx"> </span><span class="cx"> </span><span class="lines">@@ -15,9 +16,10 @@ </span><span class="cx"> class Address(ComparableEntity): </span><span class="cx"> pass </span><span class="cx"> </span><del>-class SerializeTest(testing.ORMTest): - keep_mappers = True - keep_data = True </del><ins>+class SerializeTest(MappedTest): + run_setup_mappers = 'once' + run_inserts = 'once' + run_deletes = None </ins><span class="cx"> </span><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global users, addresses </span></span></pre></div> <a id="sqlalchemybranchesrel_0_6testorm_basepy"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/rel_0_6/test/orm/_base.py (6018 => 6019)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/rel_0_6/test/orm/_base.py 2009-06-02 21:42:14 UTC (rev 6018) +++ sqlalchemy/branches/rel_0_6/test/orm/_base.py 2009-06-02 21:53:52 UTC (rev 6019) </span><span class="lines">@@ -58,15 +58,16 @@ </span><span class="cx"> self_key = sa.orm.attributes.instance_state(self).key </span><span class="cx"> except sa.orm.exc.NO_STATE: </span><span class="cx"> self_key = None </span><del>- try: - other_key = sa.orm.attributes.instance_state(other).key - except sa.orm.exc.NO_STATE: - other_key = None - - if other_key is None and self_key is not None: - a, b = other, self </del><ins>+ + if other is None: + a = self + b = other + elif self_key is not None: + a = other + b = self </ins><span class="cx"> else: </span><del>- a, b = self, other </del><ins>+ a = self + b = other </ins><span class="cx"> </span><span class="cx"> for attr in a.__dict__.keys(): </span><span class="cx"> if attr.startswith('_'): </span><span class="lines">@@ -101,19 +102,19 @@ </span><span class="cx"> # TODO: ensure instrumentation registry is empty </span><span class="cx"> </span><span class="cx"> class MappedTest(ORMTest): </span><del>- # 'once', 'foreach', None </del><ins>+ # 'once', 'each', None </ins><span class="cx"> run_define_tables = 'once' </span><span class="cx"> </span><del>- # 'once', 'foreach', None </del><ins>+ # 'once', 'each', None </ins><span class="cx"> run_setup_classes = 'once' </span><span class="cx"> </span><del>- # 'once', 'foreach', None </del><ins>+ # 'once', 'each', None </ins><span class="cx"> run_setup_mappers = 'each' </span><span class="cx"> </span><del>- # 'once', 'foreach', None </del><ins>+ # 'once', 'each', None </ins><span class="cx"> run_inserts = 'each' </span><span class="cx"> </span><del>- # 'foreach', None </del><ins>+ # 'each', None </ins><span class="cx"> run_deletes = 'each' </span><span class="cx"> </span><span class="cx"> metadata = None </span><span class="lines">@@ -197,7 +198,10 @@ </span><span class="cx"> def tearDown(self): </span><span class="cx"> sa.orm.session.Session.close_all() </span><span class="cx"> </span><del>- if self.run_setup_mappers == 'each': </del><ins>+ # 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': </ins><span class="cx"> sa.orm.clear_mappers() </span><span class="cx"> </span><span class="cx"> # no need to run deletes if tables are recreated on setup </span></span></pre></div> <a id="sqlalchemybranchesrel_0_6testormattributespy"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/rel_0_6/test/orm/attributes.py (6018 => 6019)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/rel_0_6/test/orm/attributes.py 2009-06-02 21:42:14 UTC (rev 6018) +++ sqlalchemy/branches/rel_0_6/test/orm/attributes.py 2009-06-02 21:53:52 UTC (rev 6019) </span><span class="lines">@@ -51,17 +51,18 @@ </span><span class="cx"> attributes.register_attribute(MyTest, 'user_id', uselist=False, useobject=False) </span><span class="cx"> attributes.register_attribute(MyTest, 'user_name', uselist=False, useobject=False) </span><span class="cx"> attributes.register_attribute(MyTest, 'email_address', uselist=False, useobject=False) </span><ins>+ attributes.register_attribute(MyTest, 'some_mutable_data', mutable_scalars=True, copy_function=list, compare_function=cmp, uselist=False, useobject=False) </ins><span class="cx"> attributes.register_attribute(MyTest2, 'a', uselist=False, useobject=False) </span><span class="cx"> attributes.register_attribute(MyTest2, 'b', uselist=False, useobject=False) </span><span class="cx"> # shouldnt be pickling callables at the class level </span><span class="cx"> def somecallable(*args): </span><span class="cx"> return None </span><del>- attr_name = 'mt2' - attributes.register_attribute(MyTest, attr_name, uselist = True, trackparent=True, callable_=somecallable, useobject=True) </del><ins>+ attributes.register_attribute(MyTest, "mt2", uselist = True, trackparent=True, callable_=somecallable, useobject=True) </ins><span class="cx"> </span><span class="cx"> o = MyTest() </span><span class="cx"> o.mt2.append(MyTest2()) </span><span class="cx"> o.user_id=7 </span><ins>+ o.some_mutable_data = [1,2,3] </ins><span class="cx"> o.mt2[0].a = 'abcde' </span><span class="cx"> pk_o = pickle.dumps(o) </span><span class="cx"> </span><span class="lines">@@ -100,6 +101,7 @@ </span><span class="cx"> self.assert_(o4.user_id == 7) </span><span class="cx"> self.assert_(o4.user_name is None) </span><span class="cx"> self.assert_(o4.email_address is None) </span><ins>+ self.assert_(o4.some_mutable_data == [1,2,3]) </ins><span class="cx"> self.assert_(len(o4.mt2) == 1) </span><span class="cx"> self.assert_(o4.mt2[0].a == 'abcde') </span><span class="cx"> self.assert_(o4.mt2[0].b is None) </span></span></pre></div> <a id="sqlalchemybranchesrel_0_6testorminheritanceabc_inheritancepy"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/rel_0_6/test/orm/inheritance/abc_inheritance.py (6018 => 6019)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/rel_0_6/test/orm/inheritance/abc_inheritance.py 2009-06-02 21:42:14 UTC (rev 6018) +++ sqlalchemy/branches/rel_0_6/test/orm/inheritance/abc_inheritance.py 2009-06-02 21:53:52 UTC (rev 6019) </span><span class="lines">@@ -2,14 +2,16 @@ </span><span class="cx"> from sqlalchemy import * </span><span class="cx"> from sqlalchemy.orm import * </span><span class="cx"> from sqlalchemy.orm.interfaces import ONETOMANY, MANYTOONE </span><del>-from testlib import * </del><span class="cx"> </span><ins>+from testlib import testing +from orm import _base </ins><span class="cx"> </span><ins>+ </ins><span class="cx"> def produce_test(parent, child, direction): </span><span class="cx"> """produce a testcase for A->B->C inheritance with a self-referential </span><span class="cx"> relationship between two of the classes, using either one-to-many or </span><span class="cx"> many-to-one.""" </span><del>- class ABCTest(ORMTest): </del><ins>+ class ABCTest(_base.MappedTest): </ins><span class="cx"> def define_tables(self, meta): </span><span class="cx"> global ta, tb, tc </span><span class="cx"> ta = ["a", meta] </span></span></pre></div> <a id="sqlalchemybranchesrel_0_6testorminheritanceabc_polymorphicpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/rel_0_6/test/orm/inheritance/abc_polymorphic.py (6018 => 6019)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/rel_0_6/test/orm/inheritance/abc_polymorphic.py 2009-06-02 21:42:14 UTC (rev 6018) +++ sqlalchemy/branches/rel_0_6/test/orm/inheritance/abc_polymorphic.py 2009-06-02 21:53:52 UTC (rev 6019) </span><span class="lines">@@ -2,10 +2,11 @@ </span><span class="cx"> from sqlalchemy import * </span><span class="cx"> from sqlalchemy import util </span><span class="cx"> from sqlalchemy.orm import * </span><del>-from testlib import * -from testlib import fixtures </del><span class="cx"> </span><del>-class ABCTest(ORMTest): </del><ins>+from testlib import _function_named +from orm import _base, _fixtures + +class ABCTest(_base.MappedTest): </ins><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global a, b, c </span><span class="cx"> a = Table('a', metadata, </span><span class="lines">@@ -22,7 +23,7 @@ </span><span class="cx"> </span><span class="cx"> def make_test(fetchtype): </span><span class="cx"> def test_roundtrip(self): </span><del>- class A(fixtures.Base):pass </del><ins>+ class A(_fixtures.Base):pass </ins><span class="cx"> class B(A):pass </span><span class="cx"> class C(B):pass </span><span class="cx"> </span></span></pre></div> <a id="sqlalchemybranchesrel_0_6testorminheritancebasicpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/rel_0_6/test/orm/inheritance/basic.py (6018 => 6019)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/rel_0_6/test/orm/inheritance/basic.py 2009-06-02 21:42:14 UTC (rev 6018) +++ sqlalchemy/branches/rel_0_6/test/orm/inheritance/basic.py 2009-06-02 21:53:52 UTC (rev 6019) </span><span class="lines">@@ -3,11 +3,13 @@ </span><span class="cx"> from sqlalchemy import exc as sa_exc, util </span><span class="cx"> from sqlalchemy.orm import * </span><span class="cx"> from sqlalchemy.orm import exc as orm_exc </span><del>-from testlib import * -from testlib import fixtures </del><ins>+ +#from testlib import * +#from testlib import fixtures +from testlib import _function_named, testing, engines </ins><span class="cx"> from orm import _base, _fixtures </span><span class="cx"> </span><del>-class O2MTest(ORMTest): </del><ins>+class O2MTest(_base.MappedTest): </ins><span class="cx"> """deals with inheritance and one-to-many relationships""" </span><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global foo, bar, blub </span><span class="lines">@@ -66,7 +68,7 @@ </span><span class="cx"> self.assert_(compare == result) </span><span class="cx"> self.assert_(l[0].parent_foo.data == 'foo #1' and l[1].parent_foo.data == 'foo #1') </span><span class="cx"> </span><del>-class FalseDiscriminatorTest(ORMTest): </del><ins>+class FalseDiscriminatorTest(_base.MappedTest): </ins><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global t1 </span><span class="cx"> t1 = Table('t1', metadata, Column('id', Integer, primary_key=True), Column('type', Integer, nullable=False)) </span><span class="lines">@@ -84,7 +86,7 @@ </span><span class="cx"> sess.expunge_all() </span><span class="cx"> assert isinstance(sess.query(Foo).one(), Bar) </span><span class="cx"> </span><del>-class PolymorphicSynonymTest(ORMTest): </del><ins>+class PolymorphicSynonymTest(_base.MappedTest): </ins><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global t1, t2 </span><span class="cx"> t1 = Table('t1', metadata, </span><span class="lines">@@ -96,7 +98,7 @@ </span><span class="cx"> Column('data', String(10), nullable=False)) </span><span class="cx"> </span><span class="cx"> def test_polymorphic_synonym(self): </span><del>- class T1(fixtures.Base): </del><ins>+ class T1(_fixtures.Base): </ins><span class="cx"> def info(self): </span><span class="cx"> return "THE INFO IS:" + self._info </span><span class="cx"> def _set_info(self, x): </span><span class="lines">@@ -120,7 +122,7 @@ </span><span class="cx"> self.assertEquals(at2.info, "THE INFO IS:at2") </span><span class="cx"> </span><span class="cx"> </span><del>-class CascadeTest(ORMTest): </del><ins>+class CascadeTest(_base.MappedTest): </ins><span class="cx"> """that cascades on polymorphic relations continue </span><span class="cx"> cascading along the path of the instance's mapper, not </span><span class="cx"> the base mapper.""" </span><span class="lines">@@ -148,13 +150,13 @@ </span><span class="cx"> Column('data', String(30))) </span><span class="cx"> </span><span class="cx"> def test_cascade(self): </span><del>- class T1(fixtures.Base): </del><ins>+ class T1(_fixtures.Base): </ins><span class="cx"> pass </span><del>- class T2(fixtures.Base): </del><ins>+ class T2(_fixtures.Base): </ins><span class="cx"> pass </span><span class="cx"> class T3(T2): </span><span class="cx"> pass </span><del>- class T4(fixtures.Base): </del><ins>+ class T4(_fixtures.Base): </ins><span class="cx"> pass </span><span class="cx"> </span><span class="cx"> mapper(T1, t1, properties={ </span><span class="lines">@@ -188,7 +190,7 @@ </span><span class="cx"> assert t4_1 in sess.deleted </span><span class="cx"> sess.flush() </span><span class="cx"> </span><del>-class GetTest(ORMTest): </del><ins>+class GetTest(_base.MappedTest): </ins><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global foo, bar, blub </span><span class="cx"> foo = Table('foo', metadata, </span><span class="lines">@@ -275,7 +277,7 @@ </span><span class="cx"> test_get_polymorphic = create_test(True, 'test_get_polymorphic') </span><span class="cx"> test_get_nonpolymorphic = create_test(False, 'test_get_nonpolymorphic') </span><span class="cx"> </span><del>-class EagerLazyTest(ORMTest): </del><ins>+class EagerLazyTest(_base.MappedTest): </ins><span class="cx"> """tests eager load/lazy load of child items off inheritance mappers, tests that </span><span class="cx"> LazyLoader constructs the right query condition.""" </span><span class="cx"> def define_tables(self, metadata): </span><span class="lines">@@ -321,7 +323,7 @@ </span><span class="cx"> self.assert_(len(q.first().eager) == 1) </span><span class="cx"> </span><span class="cx"> </span><del>-class FlushTest(ORMTest): </del><ins>+class FlushTest(_base.MappedTest): </ins><span class="cx"> """test dependency sorting among inheriting mappers""" </span><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global users, roles, user_roles, admins </span><span class="lines">@@ -410,7 +412,7 @@ </span><span class="cx"> sess.flush() </span><span class="cx"> assert user_roles.count().scalar() == 1 </span><span class="cx"> </span><del>-class VersioningTest(ORMTest): </del><ins>+class VersioningTest(_base.MappedTest): </ins><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global base, subtable, stuff </span><span class="cx"> base = Table('base', metadata, </span><span class="lines">@@ -431,7 +433,7 @@ </span><span class="cx"> @testing.fails_on('mssql', 'FIXME: the flush still happens with the concurrency issue.') </span><span class="cx"> @engines.close_open_connections </span><span class="cx"> def test_save_update(self): </span><del>- class Base(fixtures.Base): </del><ins>+ class Base(_fixtures.Base): </ins><span class="cx"> pass </span><span class="cx"> class Sub(Base): </span><span class="cx"> pass </span><span class="lines">@@ -479,7 +481,7 @@ </span><span class="cx"> </span><span class="cx"> @testing.fails_on('mssql', 'FIXME: the flush still happens with the concurrency issue.') </span><span class="cx"> def test_delete(self): </span><del>- class Base(fixtures.Base): </del><ins>+ class Base(_fixtures.Base): </ins><span class="cx"> pass </span><span class="cx"> class Sub(Base): </span><span class="cx"> pass </span><span class="lines">@@ -513,10 +515,12 @@ </span><span class="cx"> except orm_exc.ConcurrentModificationError, e: </span><span class="cx"> assert True </span><span class="cx"> </span><del>-class DistinctPKTest(ORMTest): </del><ins>+class DistinctPKTest(_base.MappedTest): </ins><span class="cx"> """test the construction of mapper.primary_key when an inheriting relationship </span><span class="cx"> joins on a column other than primary key column.""" </span><del>- keep_data = True </del><ins>+ + run_inserts = 'once' + run_deletes = None </ins><span class="cx"> </span><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global person_table, employee_table, Person, Employee </span><span class="lines">@@ -587,7 +591,7 @@ </span><span class="cx"> assert alice1.name == alice2.name == 'alice' </span><span class="cx"> assert bob.name == 'bob' </span><span class="cx"> </span><del>-class SyncCompileTest(ORMTest): </del><ins>+class SyncCompileTest(_base.MappedTest): </ins><span class="cx"> """test that syncrules compile properly on custom inherit conds""" </span><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global _a_table, _b_table, _c_table </span><span class="lines">@@ -653,7 +657,7 @@ </span><span class="cx"> assert len(session.query(B).all()) == 2 </span><span class="cx"> assert len(session.query(C).all()) == 1 </span><span class="cx"> </span><del>-class OverrideColKeyTest(ORMTest): </del><ins>+class OverrideColKeyTest(_base.MappedTest): </ins><span class="cx"> """test overriding of column attributes.""" </span><span class="cx"> </span><span class="cx"> def define_tables(self, metadata): </span><span class="lines">@@ -883,7 +887,7 @@ </span><span class="cx"> assert sess.query(Base).get(b1.base_id).data == "this is base" </span><span class="cx"> assert sess.query(Sub).get(s1.base_id).data == "this is base" </span><span class="cx"> </span><del>-class OptimizedLoadTest(ORMTest): </del><ins>+class OptimizedLoadTest(_base.MappedTest): </ins><span class="cx"> """test that the 'optimized load' routine doesn't crash when </span><span class="cx"> a column in the join condition is not available. </span><span class="cx"> </span><span class="lines">@@ -969,7 +973,7 @@ </span><span class="cx"> assert a.type == 2 </span><span class="cx"> </span><span class="cx"> </span><del>-class DeleteOrphanTest(ORMTest): </del><ins>+class DeleteOrphanTest(_base.MappedTest): </ins><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global single, parent </span><span class="cx"> single = Table('single', metadata, </span><span class="lines">@@ -985,13 +989,13 @@ </span><span class="cx"> ) </span><span class="cx"> </span><span class="cx"> def test_orphan_message(self): </span><del>- class Base(fixtures.Base): </del><ins>+ class Base(_fixtures.Base): </ins><span class="cx"> pass </span><span class="cx"> </span><span class="cx"> class SubClass(Base): </span><span class="cx"> pass </span><span class="cx"> </span><del>- class Parent(fixtures.Base): </del><ins>+ class Parent(_fixtures.Base): </ins><span class="cx"> pass </span><span class="cx"> </span><span class="cx"> mapper(Base, single, polymorphic_on=single.c.type, polymorphic_identity='base') </span></span></pre></div> <a id="sqlalchemybranchesrel_0_6testorminheritancemagazinepy"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/rel_0_6/test/orm/inheritance/magazine.py (6018 => 6019)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/rel_0_6/test/orm/inheritance/magazine.py 2009-06-02 21:42:14 UTC (rev 6018) +++ sqlalchemy/branches/rel_0_6/test/orm/inheritance/magazine.py 2009-06-02 21:53:52 UTC (rev 6019) </span><span class="lines">@@ -1,8 +1,9 @@ </span><span class="cx"> import testenv; testenv.configure_for_tests() </span><span class="cx"> from sqlalchemy import * </span><span class="cx"> from sqlalchemy.orm import * </span><del>-from testlib import * </del><span class="cx"> </span><ins>+from testlib import testing, _function_named +from orm import _base </ins><span class="cx"> </span><span class="cx"> class BaseObject(object): </span><span class="cx"> def __init__(self, *args, **kwargs): </span><span class="lines">@@ -68,7 +69,7 @@ </span><span class="cx"> pass </span><span class="cx"> </span><span class="cx"> </span><del>-class MagazineTest(ORMTest): </del><ins>+class MagazineTest(_base.MappedTest): </ins><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global publication_table, issue_table, location_table, location_name_table, magazine_table, \ </span><span class="cx"> page_table, magazine_page_table, classified_page_table, page_size_table </span></span></pre></div> <a id="sqlalchemybranchesrel_0_6testorminheritancemanytomanypy"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/rel_0_6/test/orm/inheritance/manytomany.py (6018 => 6019)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/rel_0_6/test/orm/inheritance/manytomany.py 2009-06-02 21:42:14 UTC (rev 6018) +++ sqlalchemy/branches/rel_0_6/test/orm/inheritance/manytomany.py 2009-06-02 21:53:52 UTC (rev 6019) </span><span class="lines">@@ -1,10 +1,12 @@ </span><span class="cx"> import testenv; testenv.configure_for_tests() </span><span class="cx"> from sqlalchemy import * </span><span class="cx"> from sqlalchemy.orm import * </span><del>-from testlib import * </del><span class="cx"> </span><ins>+from testlib import testing +from orm import _base </ins><span class="cx"> </span><del>-class InheritTest(ORMTest): </del><ins>+ +class InheritTest(_base.MappedTest): </ins><span class="cx"> """deals with inheritance and many-to-many relationships""" </span><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global principals </span><span class="lines">@@ -63,7 +65,7 @@ </span><span class="cx"> sess.flush() </span><span class="cx"> # TODO: put an assertion </span><span class="cx"> </span><del>-class InheritTest2(ORMTest): </del><ins>+class InheritTest2(_base.MappedTest): </ins><span class="cx"> """deals with inheritance and many-to-many relationships""" </span><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global foo, bar, foo_bar </span><span class="lines">@@ -136,7 +138,7 @@ </span><span class="cx"> {'id':b.id, 'data':'barfoo', 'foos':(Foo, [{'id':f1.id,'data':'subfoo1'}, {'id':f2.id,'data':'subfoo2'}])}, </span><span class="cx"> ) </span><span class="cx"> </span><del>-class InheritTest3(ORMTest): </del><ins>+class InheritTest3(_base.MappedTest): </ins><span class="cx"> """deals with inheritance and many-to-many relationships""" </span><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global foo, bar, blub, bar_foo, blub_bar, blub_foo </span></span></pre></div> <a id="sqlalchemybranchesrel_0_6testorminheritancepoly_linked_listpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/rel_0_6/test/orm/inheritance/poly_linked_list.py (6018 => 6019)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/rel_0_6/test/orm/inheritance/poly_linked_list.py 2009-06-02 21:42:14 UTC (rev 6018) +++ sqlalchemy/branches/rel_0_6/test/orm/inheritance/poly_linked_list.py 2009-06-02 21:53:52 UTC (rev 6019) </span><span class="lines">@@ -1,11 +1,14 @@ </span><span class="cx"> import testenv; testenv.configure_for_tests() </span><span class="cx"> from sqlalchemy import * </span><span class="cx"> from sqlalchemy.orm import * </span><del>-from testlib import * </del><span class="cx"> </span><ins>+from orm import _base +from testlib import testing </ins><span class="cx"> </span><del>-class PolymorphicCircularTest(ORMTest): - keep_mappers = True </del><ins>+ +class PolymorphicCircularTest(_base.MappedTest): + run_setup_mappers = 'once' + </ins><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global Table1, Table1B, Table2, Table3, Data </span><span class="cx"> table1 = Table('table1', metadata, </span></span></pre></div> <a id="sqlalchemybranchesrel_0_6testorminheritancepolymorphpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/rel_0_6/test/orm/inheritance/polymorph.py (6018 => 6019)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/rel_0_6/test/orm/inheritance/polymorph.py 2009-06-02 21:42:14 UTC (rev 6018) +++ sqlalchemy/branches/rel_0_6/test/orm/inheritance/polymorph.py 2009-06-02 21:53:52 UTC (rev 6019) </span><span class="lines">@@ -4,10 +4,10 @@ </span><span class="cx"> from sqlalchemy import * </span><span class="cx"> from sqlalchemy.orm import * </span><span class="cx"> from sqlalchemy.orm import exc as orm_exc </span><del>-from testlib import * -from testlib import fixtures </del><ins>+from testlib import _function_named, Column, testing +from orm import _fixtures, _base </ins><span class="cx"> </span><del>-class Person(fixtures.Base): </del><ins>+class Person(_fixtures.Base): </ins><span class="cx"> pass </span><span class="cx"> class Engineer(Person): </span><span class="cx"> pass </span><span class="lines">@@ -15,10 +15,10 @@ </span><span class="cx"> pass </span><span class="cx"> class Boss(Manager): </span><span class="cx"> pass </span><del>-class Company(fixtures.Base): </del><ins>+class Company(_fixtures.Base): </ins><span class="cx"> pass </span><span class="cx"> </span><del>-class PolymorphTest(ORMTest): </del><ins>+class PolymorphTest(_base.MappedTest): </ins><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global companies, people, engineers, managers, boss </span><span class="cx"> </span></span></pre></div> <a id="sqlalchemybranchesrel_0_6testorminheritancepolymorph2py"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/rel_0_6/test/orm/inheritance/polymorph2.py (6018 => 6019)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/rel_0_6/test/orm/inheritance/polymorph2.py 2009-06-02 21:42:14 UTC (rev 6018) +++ sqlalchemy/branches/rel_0_6/test/orm/inheritance/polymorph2.py 2009-06-02 21:53:52 UTC (rev 6019) </span><span class="lines">@@ -6,9 +6,9 @@ </span><span class="cx"> from sqlalchemy import * </span><span class="cx"> from sqlalchemy import util </span><span class="cx"> from sqlalchemy.orm import * </span><del>-from testlib import * -from testlib import fixtures -from orm import _base </del><ins>+ +from testlib import _function_named, TestBase, AssertsExecutionResults, testing +from orm import _base, _fixtures </ins><span class="cx"> from testlib.testing import eq_ </span><span class="cx"> </span><span class="cx"> class AttrSettable(object): </span><span class="lines">@@ -18,7 +18,7 @@ </span><span class="cx"> return self.__class__.__name__ + "(%s)" % (hex(id(self))) </span><span class="cx"> </span><span class="cx"> </span><del>-class RelationTest1(ORMTest): </del><ins>+class RelationTest1(_base.MappedTest): </ins><span class="cx"> """test self-referential relationships on polymorphic mappers""" </span><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global people, managers </span><span class="lines">@@ -97,7 +97,7 @@ </span><span class="cx"> print p, m, m.employee </span><span class="cx"> assert m.employee is p </span><span class="cx"> </span><del>-class RelationTest2(ORMTest): </del><ins>+class RelationTest2(_base.MappedTest): </ins><span class="cx"> """test self-referential relationships on polymorphic mappers""" </span><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global people, managers, data </span><span class="lines">@@ -192,7 +192,7 @@ </span><span class="cx"> if usedata: </span><span class="cx"> assert m.data.data == 'ms data' </span><span class="cx"> </span><del>-class RelationTest3(ORMTest): </del><ins>+class RelationTest3(_base.MappedTest): </ins><span class="cx"> """test self-referential relationships on polymorphic mappers""" </span><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global people, managers, data </span><span class="lines">@@ -298,7 +298,7 @@ </span><span class="cx"> setattr(RelationTest3, func.__name__, func) </span><span class="cx"> </span><span class="cx"> </span><del>-class RelationTest4(ORMTest): </del><ins>+class RelationTest4(_base.MappedTest): </ins><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global people, engineers, managers, cars </span><span class="cx"> people = Table('people', metadata, </span><span class="lines">@@ -410,7 +410,7 @@ </span><span class="cx"> c = s.join("employee").filter(Person.name=="E4")[0] </span><span class="cx"> assert c.car_id==car1.car_id </span><span class="cx"> </span><del>-class RelationTest5(ORMTest): </del><ins>+class RelationTest5(_base.MappedTest): </ins><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global people, engineers, managers, cars </span><span class="cx"> people = Table('people', metadata, </span><span class="lines">@@ -470,7 +470,7 @@ </span><span class="cx"> assert carlist[0].manager is None </span><span class="cx"> assert carlist[1].manager.person_id == car2.manager.person_id </span><span class="cx"> </span><del>-class RelationTest6(ORMTest): </del><ins>+class RelationTest6(_base.MappedTest): </ins><span class="cx"> """test self-referential relationships on a single joined-table inheritance mapper""" </span><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global people, managers, data </span><span class="lines">@@ -513,7 +513,7 @@ </span><span class="cx"> m2 = sess.query(Manager).get(m2.person_id) </span><span class="cx"> assert m.colleague is m2 </span><span class="cx"> </span><del>-class RelationTest7(ORMTest): </del><ins>+class RelationTest7(_base.MappedTest): </ins><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global people, engineers, managers, cars, offroad_cars </span><span class="cx"> cars = Table('cars', metadata, </span><span class="lines">@@ -612,7 +612,7 @@ </span><span class="cx"> for p in r: </span><span class="cx"> assert p.car_id == p.car.car_id </span><span class="cx"> </span><del>-class RelationTest8(ORMTest): </del><ins>+class RelationTest8(_base.MappedTest): </ins><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global taggable, users </span><span class="cx"> taggable = Table('taggable', metadata, </span><span class="lines">@@ -783,7 +783,7 @@ </span><span class="cx"> r = session.query(Person).filter(exists([1], Car.owner==Person.person_id)) </span><span class="cx"> assert str(list(r)) == "[Engineer E4, field X, status Status dead]" </span><span class="cx"> </span><del>-class MultiLevelTest(ORMTest): </del><ins>+class MultiLevelTest(_base.MappedTest): </ins><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global table_Employee, table_Engineer, table_Manager </span><span class="cx"> table_Employee = Table( 'Employee', metadata, </span><span class="lines">@@ -860,7 +860,7 @@ </span><span class="cx"> assert set(session.query( Engineer).all()) == set([b,c]) </span><span class="cx"> assert session.query( Manager).all() == [c] </span><span class="cx"> </span><del>-class ManyToManyPolyTest(ORMTest): </del><ins>+class ManyToManyPolyTest(_base.MappedTest): </ins><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global base_item_table, item_table, base_item_collection_table, collection_table </span><span class="cx"> base_item_table = Table( </span><span class="lines">@@ -910,7 +910,7 @@ </span><span class="cx"> </span><span class="cx"> class_mapper(BaseItem) </span><span class="cx"> </span><del>-class CustomPKTest(ORMTest): </del><ins>+class CustomPKTest(_base.MappedTest): </ins><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global t1, t2 </span><span class="cx"> t1 = Table('t1', metadata, </span><span class="lines">@@ -993,7 +993,7 @@ </span><span class="cx"> ot1.data = 'hi' </span><span class="cx"> sess.flush() </span><span class="cx"> </span><del>-class InheritingEagerTest(ORMTest): </del><ins>+class InheritingEagerTest(_base.MappedTest): </ins><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global people, employees, tags, peopleTags </span><span class="cx"> </span><span class="lines">@@ -1020,14 +1020,14 @@ </span><span class="cx"> def test_basic(self): </span><span class="cx"> """test that Query uses the full set of mapper._eager_loaders when generating SQL""" </span><span class="cx"> </span><del>- class Person(fixtures.Base): </del><ins>+ class Person(_fixtures.Base): </ins><span class="cx"> pass </span><span class="cx"> </span><span class="cx"> class Employee(Person): </span><span class="cx"> def __init__(self, name='bob'): </span><span class="cx"> self.name = name </span><span class="cx"> </span><del>- class Tag(fixtures.Base): </del><ins>+ class Tag(_fixtures.Base): </ins><span class="cx"> def __init__(self, label): </span><span class="cx"> self.label = label </span><span class="cx"> </span><span class="lines">@@ -1054,7 +1054,7 @@ </span><span class="cx"> instance = session.query(Employee).filter_by(id=1).limit(1).first() </span><span class="cx"> assert len(instance.tags) == 2 </span><span class="cx"> </span><del>-class MissingPolymorphicOnTest(ORMTest): </del><ins>+class MissingPolymorphicOnTest(_base.MappedTest): </ins><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global tablea, tableb, tablec, tabled </span><span class="cx"> tablea = Table('tablea', metadata, </span><span class="lines">@@ -1076,9 +1076,9 @@ </span><span class="cx"> ) </span><span class="cx"> </span><span class="cx"> def test_polyon_col_setsup(self): </span><del>- class A(fixtures.Base): </del><ins>+ class A(_fixtures.Base): </ins><span class="cx"> pass </span><del>- class B(fixtures.Base): </del><ins>+ class B(_fixtures.Base): </ins><span class="cx"> pass </span><span class="cx"> class C(A): </span><span class="cx"> pass </span></span></pre></div> <a id="sqlalchemybranchesrel_0_6testorminheritanceproductspecpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/rel_0_6/test/orm/inheritance/productspec.py (6018 => 6019)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/rel_0_6/test/orm/inheritance/productspec.py 2009-06-02 21:42:14 UTC (rev 6018) +++ sqlalchemy/branches/rel_0_6/test/orm/inheritance/productspec.py 2009-06-02 21:53:52 UTC (rev 6019) </span><span class="lines">@@ -2,10 +2,13 @@ </span><span class="cx"> from datetime import datetime </span><span class="cx"> from sqlalchemy import * </span><span class="cx"> from sqlalchemy.orm import * </span><del>-from testlib import * </del><span class="cx"> </span><span class="cx"> </span><del>-class InheritTest(ORMTest): </del><ins>+from testlib import testing +from orm import _base + + +class InheritTest(_base.MappedTest): </ins><span class="cx"> """tests some various inheritance round trips involving a particular set of polymorphic inheritance relationships""" </span><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global products_table, specification_table, documents_table </span></span></pre></div> <a id="sqlalchemybranchesrel_0_6testorminheritancequerypy"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/rel_0_6/test/orm/inheritance/query.py (6018 => 6019)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/rel_0_6/test/orm/inheritance/query.py 2009-06-02 21:42:14 UTC (rev 6018) +++ sqlalchemy/branches/rel_0_6/test/orm/inheritance/query.py 2009-06-02 21:53:52 UTC (rev 6019) </span><span class="lines">@@ -1,23 +1,18 @@ </span><del>-"""tests the Query object's ability to work with polymorphic selectables -and inheriting mappers.""" - -# TODO: under construction ! - </del><span class="cx"> import testenv; testenv.configure_for_tests() </span><span class="cx"> from sqlalchemy import * </span><span class="cx"> from sqlalchemy.orm import * </span><span class="cx"> from sqlalchemy import exc as sa_exc </span><del>-from testlib import * -from testlib import fixtures -from orm import _base -from testlib.testing import eq_ </del><span class="cx"> from sqlalchemy.ext.declarative import declarative_base </span><span class="cx"> from sqlalchemy.engine import default </span><span class="cx"> </span><del>-class Company(fixtures.Base): </del><ins>+from testlib import AssertsCompiledSQL, testing +from orm import _base, _fixtures +from testlib.testing import eq_ + +class Company(_fixtures.Base): </ins><span class="cx"> pass </span><span class="cx"> </span><del>-class Person(fixtures.Base): </del><ins>+class Person(_fixtures.Base): </ins><span class="cx"> pass </span><span class="cx"> class Engineer(Person): </span><span class="cx"> pass </span><span class="lines">@@ -26,17 +21,18 @@ </span><span class="cx"> class Boss(Manager): </span><span class="cx"> pass </span><span class="cx"> </span><del>-class Machine(fixtures.Base): </del><ins>+class Machine(_fixtures.Base): </ins><span class="cx"> pass </span><span class="cx"> </span><del>-class Paperwork(fixtures.Base): </del><ins>+class Paperwork(_fixtures.Base): </ins><span class="cx"> pass </span><span class="cx"> </span><span class="cx"> def make_test(select_type): </span><del>- class PolymorphicQueryTest(ORMTest, AssertsCompiledSQL): - keep_data = True - keep_mappers = True - </del><ins>+ class PolymorphicQueryTest(_base.MappedTest, AssertsCompiledSQL): + run_inserts = 'once' + run_setup_mappers = 'once' + run_deletes = None + </ins><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global companies, people, engineers, managers, boss, paperwork, machines </span><span class="cx"> </span><span class="lines">@@ -718,8 +714,8 @@ </span><span class="cx"> </span><span class="cx"> del testclass </span><span class="cx"> </span><del>-class SelfReferentialTestJoinedToBase(ORMTest): - keep_mappers = True </del><ins>+class SelfReferentialTestJoinedToBase(_base.MappedTest): + run_setup_mappers = 'once' </ins><span class="cx"> </span><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global people, engineers </span><span class="lines">@@ -734,6 +730,7 @@ </span><span class="cx"> Column('reports_to_id', Integer, ForeignKey('people.person_id')) </span><span class="cx"> ) </span><span class="cx"> </span><ins>+ def setup_mappers(self): </ins><span class="cx"> mapper(Person, people, polymorphic_on=people.c.type, polymorphic_identity='person') </span><span class="cx"> mapper(Engineer, engineers, inherits=Person, </span><span class="cx"> inherit_condition=engineers.c.person_id==people.c.person_id, </span><span class="lines">@@ -775,11 +772,11 @@ </span><span class="cx"> sess.query(Engineer).join('reports_to', aliased=True).filter(Person.name=='dogbert').first(), </span><span class="cx"> Engineer(name='dilbert')) </span><span class="cx"> </span><del>-class SelfReferentialJ2JTest(ORMTest): - keep_mappers = True </del><ins>+class SelfReferentialJ2JTest(_base.MappedTest): + run_setup_mappers = 'once' </ins><span class="cx"> </span><span class="cx"> def define_tables(self, metadata): </span><del>- global people, engineers </del><ins>+ global people, engineers, managers </ins><span class="cx"> people = Table('people', metadata, </span><span class="cx"> Column('person_id', Integer, Sequence('person_id_seq', optional=True), primary_key=True), </span><span class="cx"> Column('name', String(50)), </span><span class="lines">@@ -795,6 +792,7 @@ </span><span class="cx"> Column('person_id', Integer, ForeignKey('people.person_id'), primary_key=True), </span><span class="cx"> ) </span><span class="cx"> </span><ins>+ def setup_mappers(self): </ins><span class="cx"> mapper(Person, people, polymorphic_on=people.c.type, polymorphic_identity='person') </span><span class="cx"> mapper(Manager, managers, inherits=Person, polymorphic_identity='manager') </span><span class="cx"> </span><span class="lines">@@ -885,12 +883,13 @@ </span><span class="cx"> </span><span class="cx"> </span><span class="cx"> </span><del>-class M2MFilterTest(ORMTest): - keep_mappers = True - keep_data = True </del><ins>+class M2MFilterTest(_base.MappedTest): + run_setup_mappers = 'once' + run_inserts = 'once' + run_deletes = None </ins><span class="cx"> </span><span class="cx"> def define_tables(self, metadata): </span><del>- global people, engineers, Organization </del><ins>+ global people, engineers, organizations, engineers_to_org </ins><span class="cx"> </span><span class="cx"> organizations = Table('organizations', metadata, </span><span class="cx"> Column('id', Integer, Sequence('org_id_seq', optional=True), primary_key=True), </span><span class="lines">@@ -910,8 +909,10 @@ </span><span class="cx"> Column('person_id', Integer, ForeignKey('people.person_id'), primary_key=True), </span><span class="cx"> Column('primary_language', String(50)), </span><span class="cx"> ) </span><del>- - class Organization(fixtures.Base): </del><ins>+ + def setup_mappers(self): + global Organization + class Organization(_fixtures.Base): </ins><span class="cx"> pass </span><span class="cx"> </span><span class="cx"> mapper(Organization, organizations, properties={ </span><span class="lines">@@ -950,17 +951,18 @@ </span><span class="cx"> self.assertEquals(sess.query(Organization).filter(Organization.engineers.of_type(Engineer).any(Engineer.name=='e1')).all(), [Organization(name='org1')]) </span><span class="cx"> self.assertEquals(sess.query(Organization).filter(Organization.engineers.any(Engineer.name=='e1')).all(), [Organization(name='org1')]) </span><span class="cx"> </span><del>-class SelfReferentialM2MTest(ORMTest, AssertsCompiledSQL): - keep_mappers = True </del><ins>+class SelfReferentialM2MTest(_base.MappedTest, AssertsCompiledSQL): + run_setup_mappers = 'once' </ins><span class="cx"> </span><span class="cx"> def define_tables(self, metadata): </span><ins>+ global Parent, Child1, Child2 + </ins><span class="cx"> Base = declarative_base(metadata=metadata) </span><span class="cx"> </span><span class="cx"> secondary_table = Table('secondary', Base.metadata, </span><span class="cx"> Column('left_id', Integer, ForeignKey('parent.id'), nullable=False), </span><span class="cx"> Column('right_id', Integer, ForeignKey('parent.id'), nullable=False)) </span><del>- - global Parent, Child1, Child2 </del><ins>+ </ins><span class="cx"> class Parent(Base): </span><span class="cx"> __tablename__ = 'parent' </span><span class="cx"> id = Column(Integer, primary_key=True) </span></span></pre></div> <a id="sqlalchemybranchesrel_0_6testorminheritanceselectspy"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/rel_0_6/test/orm/inheritance/selects.py (6018 => 6019)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/rel_0_6/test/orm/inheritance/selects.py 2009-06-02 21:42:14 UTC (rev 6018) +++ sqlalchemy/branches/rel_0_6/test/orm/inheritance/selects.py 2009-06-02 21:53:52 UTC (rev 6019) </span><span class="lines">@@ -1,11 +1,13 @@ </span><span class="cx"> import testenv; testenv.configure_for_tests() </span><span class="cx"> from sqlalchemy import * </span><span class="cx"> from sqlalchemy.orm import * </span><del>-from testlib import * -from testlib.fixtures import Base </del><span class="cx"> </span><ins>+from testlib import testing +from orm._fixtures import Base +from orm._base import MappedTest </ins><span class="cx"> </span><del>-class InheritingSelectablesTest(ORMTest): </del><ins>+ +class InheritingSelectablesTest(MappedTest): </ins><span class="cx"> def define_tables(self, metadata): </span><span class="cx"> global foo, bar, baz </span><span class="cx"> foo = Table('foo', metadata, </span></span></pre></div> <a id="sqlalchemybranchesrel_0_6testorminheritancesinglepy"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/rel_0_6/test/orm/inheritance/single.py (6018 => 6019)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/rel_0_6/test/orm/inheritance/single.py 2009-06-02 21:42:14 UTC (rev 6018) +++ sqlalchemy/branches/rel_0_6/test/orm/inheritance/single.py 2009-06-02 21:53:52 UTC (rev 6019) </span><span class="lines">@@ -1,8 +1,9 @@ </span><span class="cx"> import testenv; testenv.configure_for_tests() </span><span class="cx"> from sqlalchemy import * </span><span class="cx"> from sqlalchemy.orm import * </span><del>-from testlib import * -from testlib.fixtures import Base </del><ins>+ +from testlib import testing +from orm import _fixtures </ins><span class="cx"> from orm._base import MappedTest, ComparableEntity </span><span class="cx"> </span><span class="cx"> </span><span class="lines">@@ -330,7 +331,7 @@ </span><span class="cx"> ) </span><span class="cx"> go() </span><span class="cx"> </span><del>-class SingleOnJoinedTest(ORMTest): </del><ins>+class SingleOnJoinedTest(MappedTest): </ins><span class="cx"> def define... [truncated message content] |