Skip to content

pytest-plone

PyPI PyPI - Python Version PyPI - Wheel PyPI - License PyPI - Status

PyPI - Plone Versions

Tests

Code Style

GitHub contributors GitHub Repo stars

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

Installation

pip install pytest-plone

Quickstart

In 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:

Contributing

You need a working Python environment, version 3.10 or later.

Install a development environment and run the tests with:

make install
make test

By default the tests run against the latest Plone version in the 6.x series.

Documentation is built with:

make docs

License

The project is licensed under the GPLv2.

About

Pytest plugin to test Plone addons

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

Used by

Contributors

Languages