[Zope] unit testing and committing transactions

Karl Anderson kra at monkey.org
Mon Mar 22 20:30:41 EST 2004


"Stefan H. Holek" <stefan at epy.co.at> writes:

> On Dienstag, Mär 23, 2004, at 00:03 Europe/Vienna, Karl Anderson wrote:
> 
> >
> > def makeNewDB():
> >     """
> >     Overwrite the custom_zodb DemoStorage with a new one, then call 
> > startup
> >     to make a new DB.  This is needed when we want a clean slate after
> >     a transaction has been committed.
> >     """
> >     m = imp.find_module('custom_zodb', [TESTING_HOME])
> >     m = imp.load_module('Zope.custom_zodb', m[0], m[1], m[2])
> >     m.Storage = DemoStorage(quota=(1<<20))
> >     # call the app startup manually - it won't be called by 
> > Zope.startup()
> >     # more than once.  This only works after a call to Zope.app().
> >     Zope.App.startup.startup()
> >
> 
> You can replace the above with 'import Testing'. This modifies the 
> configuration and Zope.app() will do the right thing (tm). Neat, huh?

Nope, I'm already using testrunner.py, so I'm already using the
DemoStorage in its custom_zodb.py.  If a transaction is committed,
then changes still persist.

> You may also be interested in the ZopeTestCase package which takes care 
> of all these things for you: <http://zope.org/Members/shh/ZopeTestCase>

Thanks, I'll look into it.  I'm already using your
DEATH_TO_INSTANCE_HOME patch modified for 2.6.x, so that'd be nicer
anyway.

-- 
Karl Anderson      kra at monkey.org           http://monkey.org/~kra/



More information about the Zope mailing list