Integration of zope.testrunner-style test layers into py.test framework
Integration of zope.testrunner-style test layers into the py.test framework
This package is compatible with Python versions 2.6 and 2.7. (To run its tests successfully you should use at least Python 2.7.4 because of a bug in earlier Python 2.7 versions.)
Make sure your test files follow the conventions of py.test’s test discovery
In particular, a file named tests.py will not be recognised.
Add a buildout section to create the
[buildout] parts += pytest [pytest] recipe = zc.recipe.egg eggs = gocept.pytestlayer pytest <YOUR PACKAGE HERE>
gocept.pytestlayer registers itself as a py.test plugin. This way, nothing more is needed to run an existing Zope or Plone test suite.
Version 2.1 reintroduced
fixture.create() to be able to define the name of the generated to py.test fixtures. So it is possible to use them in function style tests.
Example (Code has to be in
from .testing import FUNCTIONAL_LAYER import gocept.pytestlayer.fixture globals().update(gocept.pytestlayer.fixture.create( FUNCTIONAL_LAYER, session_fixture_name='functional_session', class_fixture_name='functional_class', function_fixture_name='functional'))
This creates three fixtures with the given names and the scopes in the argument name. The session and class fixtures run
tearDown() of the layer if it has not been run before while the function fixture runs
testTearDown() of the layer. The function fixture depends on the session one. The fixtures return the instance of the layer. So you can use the
functional fixture like this:
def test_mymodule__my_function__1(functional): assert functional['app'] is not None
py.testtest discovery which ignores the doctests in this case.
|Author:||gocept <email@example.com>, Godefroid Chapelle <firstname.lastname@example.org>|
|Current change log:|
setuptools >= 30.0.
pytest >= 3.0is used for testing.