I'm happy to announce the release of pytest-plone 1.1.0, available now on PyPI.
This is the first feature release since the package moved to the plone organization and reached 1.0.0. The package is now marked Production/Stable, ships real documentation, and fixes a performance issue that affected any suite relying on function-style tests.
Highlights
Documentation
pytest-plone now has a full documentation set built with Sphinx and organised around the Diataxis framework: a tutorial, four how-to guides, two explanation pages, and a generated fixture/API reference. The reference is generated from the docstrings with sphinx-autodoc2, which analyses the source statically โ so it handles both @pytest.fixture objects and our Markdown docstrings. Build it locally with make docs.
Faster test runs
Function-style tests (def test_x(portal): ...) previously re-ran the full testing-layer setUp โ including applyProfile โ once per test instead of once per session. fixtures_factory now keeps each layer set up for the whole session via an autouse session fixture per layer. Pass keep_session=False to restore the previous behavior.
Measured results on real codebases:
| Codebase | Tests | 1.0.0 | 1.1.0 | Result |
|---|---|---|---|---|
| pas.plugins.authomatic | 144 | 32.13s | 4.15s | 7.7x faster |
| collective.person | 66 | 26.14s | 6.43s | 4.1x faster |
| tech-event | 553 | 167.18s | 62.10s | 2.7x faster |
| kitconcept.intranet | 279 | 230.93s | 136.69s | 1.7x faster |
| plonegovbr.brfields | 20 | 4.30s | 2.65s | 1.62x faster |
If your tests modify an existing site or create a new one, make sure to revert those changes at the end of the test.
New fixtures and markers
-
@pytest.mark.portalcan now create content in a specific container (_container) and transition it to a workflow state (_review_state). -
New class-scoped
app_classandfunctional_app_classfixtures return the Zope app root at class scope. -
plone.distributionsupport: acreate_sitefixture that creates a Plone site from a distribution, plus overridabledistribution_name,answers,site_logo,site_owner_nameandsite_owner_passwordfixtures.
Documentation fixes
Several fixture docstring examples were not valid Python (unterminated strings, isinstance vs providedBy, undefined names, self in top-level test functions). They have been fixed and are now guarded by a test that executes them, so they stay correct.
Install
uv add --dev pytest-plone
or:
pip install pytest-plone
Links
-
Changelog: pytest-plone/CHANGELOG.md at main ยท plone/pytest-plone ยท GitHub
-
Documentation: pytest-plone โ pytest-plone v1.1.1.dev0
-
Repository: GitHub - plone/pytest-plone: Pytest plugin to test Plone addons ยท GitHub
Special thanks to @jensens, who drove most of this release โ the documentation, the performance fix, and the docstring cleanup.