[Zope-dev] Puzzle re zope.pytest

Jeff Rush jrush at taupro.com
Wed May 16 08:40:17 UTC 2012


Are many folks using zope.pytest?  We're looking into it but, for such a
small amount of code, are finding it a bit odd and seemingly broken.

Breaking down the basic creation of an application object, here is what
the code does, with indentation to show what a method call performs:

create_app()
  db = setup_db()
    storage = DemoStorage(name)
    db = DB(storage, database_name=name)
    db.setActivityMonitor( ZODB.ActivityMonitor.ActivityMonitor() )
    notify( zope.processlifetime.DatabaseOpened(db) )
    return db
  connection = setup_connection(db)
    return db.open()
  connection.root()[ZopePublication.root_name]['test'] = site_root

My issues are:

1) the DatabaseOpened event is sent out _before_ the ZODB is actually
opened, making it hard to use handlers to initialize a test layout in
the ZODB.

2) there are no other events emitted, such as after root is initialized.

3) there is a key lookup of "ZopePublication.root_name" inside
connection.root() before any code has _set_ such a key, raising a key
lookup exception in my basic evaluation pgm.

4) there are no examples of tests that use the 'test' subscript, and I'm
puzzled by the extra level of indirection instead of just using
ZopePublication.root_name in test_XXX functions.

5) the unit tests for zope.pytest itself are failing with:
>   from zope.interface.interfaces import ComponentLookupError
E   ImportError: cannot import name ComponentLookupError

I've googled to find others using zope.pytest, to see examples of
correct usage in a ZODB-based testing environment, without luck.

-Jeff


More information about the Zope-Dev mailing list