Helpers for py.test integration in Zope-based environments.
The main test helpers are the first two functions (create_app(), configure()) which are normally accessed deploying the py.test funcarg mechanism.
Get a WSGI publisher application.
Returns a zope.app.wsgi.WSGIPublisherApplication with site_root stored in the root folder under the name test.
This function is meant to be used as setup/teardown handler deploying a pytest_funcarg__ function.
It sets up a ZODB connection to a ZODB DemoStorage and adds finalizers (tear_down-functionality for people from other testing frameworks) to shutdown the whole setup after the test session.
The request parameter is expected to be a py.test FuncargRequest (not an HTTP request or similar) which is generated by py.test while running tests.
The handle_errors attribute of the returned application is set to False so that errors are handled by the server.
To make use of this setup, you have to configure the environment properly before. Most notably you have to register basic components that subscribe to IDatabaseOpenedEvents, etc. This can normally be done using configure() or setup_config().
See also
pytest_funcarg__ docs on pytest.org.
Configure the environment.
Performs a ZCML-driven configuration.
You normally run this function before calling create_app() as it registers basic components and event subscribers that become active when a ZODB connection is created and opened.
This function is normally called in a pytest_funcarg__ function which will be executed before your test.
It adds cached setup and teardown code to be run before and after your session. That means the configuration setup and teardown will happen only once for a complete test run.
See also
pytest_funcarg__ docs on pytest.org.
Setup a configuration.
Execute the configuration specified by package and zcml_file.
This is a helper function used by configure(). You normally use configure() to setup tests.
The function registers the most common directives and then tries to parse the and execute the configuration as given in the ZCML file.
Returns the resulting ZCML configuration.
Clean up a ZCML configuration.
Unregisters components registered.
Create a ZODB DB with a demo storage.
Creates a ZODB DemoStorage, turns it into a ZODB DB named main and sends a DatebaseOpened event to inform other components.
You normally have to configure the Zope Component Architechture using setup_config() or (preferably) configure() before you call this function.
Returns a ZODB DB.
Open a connection to db.
Returns a connection to the database.
Shutdown ZODB DB connection.
Aborts any running transaction and closes the connection.
Get the application root.
Returns the Zope application root from a ZODB DB connected to by connection.
Return the application root, i.e. the object that contains the global site manager and other fundamental ZCA-related stuff.