mò Sã¸Ec@sudZdkZdkZdkZdkZdklZdklZd„Z d„Z e djoei ƒndS(sUTest broken-object suppport $Id: testBroken.py 29896 2005-04-07 04:48:06Z tim_one $ N(s DocTestSuite(sDBcCsdS(s8Test the integration of broken object support with the databse: >>> db = DB() We'll create a fake module with a class: >>> class NotThere: ... Atall = type('Atall', (persistent.Persistent, ), ... {'__module__': 'ZODB.not.there'}) And stuff this into sys.modules to simulate a regular module: >>> sys.modules['ZODB.not.there'] = NotThere >>> sys.modules['ZODB.not'] = NotThere Now, we'll create and save an instance, and make sure we can load it in another connection: >>> a = NotThere.Atall() >>> a.x = 1 >>> conn1 = db.open() >>> conn1.root()['a'] = a >>> transaction.commit() >>> conn2 = db.open() >>> a2 = conn2.root()['a'] >>> a2.__class__ is a.__class__ True >>> a2.x 1 Now, we'll uninstall the module, simulating having the module go away: >>> del sys.modules['ZODB.not.there'] and we'll try to load the object in another connection: >>> conn3 = db.open() >>> a3 = conn3.root()['a'] >>> a3 >>> a3.__Broken_state__ {'x': 1} Let's clean up: >>> db.close() >>> del sys.modules['ZODB.not'] Cleanup: >>> import ZODB.broken >>> ZODB.broken.broken_cache.clear() N((((t4/data/zmath/zope/lib/python/ZODB/tests/testBroken.pyttest_integrations*cCstitdƒtƒfƒS(Ns ZODB.broken(tunittestt TestSuitet DocTestSuite(((Rt test_suiteUst__main__( t__doc__tsysRt persistentt transactiontzope.testing.doctestRtZODB.tests.utiltDBRRt__name__tmain(R RR R RRRR((Rt?s       ;