How to test a Plone add-on easily
A quick primer into how to get the testing environment of most common Plone add-ons going.
This example is based on collective.exportimport. It assumes you are running on a recent Fedora release, that you have a terminal window open, and you have the source code of the add-on you're testing.
# Install Fedora Toolbox. This lets you create infinite
# sandboxes to test your code in the most arbitrary of
# environments.
sudo dnf install -y /usr/bin/toolbox
# Change to your source code directory, and spawn a new sandbox.
cd /your/source/code
toolbox create -r 34
toolbox enter -r 34
# From here on, you are running on a Fedora 34 container, which
# happens to also have your source code in the current directory.
# Nothing you touch outside your home directory is going to
# affect your operating system.
# This command installs (to your container) the minimum to compile
# Python and Zope dependencies.
sudo dnf install -y libpng-devel libjpeg-turbo-devel make gcc bzip2-devel openssl-devel readline-devel sqlite3-devel libffi-devel
# Install pyenv in your Toolbox sandbox.
curl https://pyenv.run | bash
# Put pyenv to work in your terminal session's environment.
export PATH="$HOME/.pyenv/bin:$PATH" eval "$(pyenv init --path)" eval "$(pyenv virtualenv-init -)"
# Install Python (in this example 2.7.18) and associate
# the Python version with a new env.
pyenv install 2.7.18
pyenv virtualenv 2.7.18 nameofyourenv-py2
pyenv local nameofyourenv-py2
# Install and buildout.
pip install -r requirements.txt
buildout
That is all you need to get started.
What next?
Try bin/test
immediately afterwards, to get the tests of the add-on running — this command is the customary test runner for Plone add-ons.