pytest-plone is a pytest plugin providing fixtures and helpers to test Plone add-ons.
It builds on zope.pytestlayer, turning the plone.testing layers you already have into pytest fixtures.
📖 Documentation: plone.github.io/pytest-plone
pip install pytest-ploneIn your top-level conftest.py, import your testing layers and hand them to fixtures_factory with a prefix for each:
from my.addon.testing import MY_ADDON_FUNCTIONAL_TESTING
from my.addon.testing import MY_ADDON_INTEGRATION_TESTING
from pytest_plone import fixtures_factory
pytest_plugins = ["pytest_plone"]
globals().update(
fixtures_factory((
(MY_ADDON_FUNCTIONAL_TESTING, "functional"),
(MY_ADDON_INTEGRATION_TESTING, "integration"),
))
)Then write tests as plain functions that ask for what they need:
def test_portal_title(portal):
assert portal.title == "Plone site"Run them with pytest.
The documentation covers the rest:
- Write your first test — a guided start for a new add-on.
- How-to guides — set up the plugin, test add-on install, test a REST API, speed up a slow suite.
- Fixtures reference — every fixture, the
@pytest.mark.portalmarker, and thefixtures_factoryAPI. - Testing layers, scopes, and isolation — how it all fits together.
You need a working Python environment, version 3.10 or later.
Install a development environment and run the tests with:
make install
make testBy default the tests run against the latest Plone version in the 6.x series.
Documentation is built with:
make docsThe project is licensed under the GPLv2.