- Use gocept.pytestlayer.
We have many test suites which use test layers (e. g. the ones from plone.testing). We want to use py.test and all its fancy features to have a modern test runner. There was no way to convert such tests partly: either you have to port the whole project or you are stuck with the zope.testrunner.
For each layer it creates two fixtures: one for the layer setUp/tearDown and one for the testSetUp/testTearDown. The layer fixture is configured for class scope but the plug-in orders the tests and knows about the next test so the layer is only torn down if the next test needs another fixture.
You only have to add a new section to your package buildout and running the test via
detects the layers and displays the needed setup code. See the PyPI-Page of the package for details.
Maybe it is possible to get rid of the fixture setup code, so running tests using layers gets even easier.