Testing with toxΒΆ
The pypfilt testing suite uses the pytest
framework, and uses the tox automation tool
to run the tests under Python 2 and Python 3.
The test cases are contained in the ./tests
directory.
To run all tests using all of the Python versions defined in tox.ini
, run:
tox
The tox.ini
contents are shown below, and include targets that check
whether the documentation in ./doc
builds correctly with Python 2 and with
Python 3.
#
# Configuration file for tox, used to automate test activities.
#
# https://tox.readthedocs.io/en/latest/
#
# This configuration file defines four test environments:
#
# py27-test: Run the test cases in ./tests/ using Python 2.7.
# py35-test: Run the test cases in ./tests/ using Python 3.5.
# py27-docs: Build the package documentation using Python 2.7.
# py35-docs: Build the package documentation using Python 3.5.
#
# To perform each of these test activities, run:
#
# tox
#
[tox]
envlist = py{27,35}-{test,docs}
#
# Define common settings.
#
# * Cache installed wheels to accelerate environment creation.
# * Ensure tests are run against the installed package.
# * Add test-specific package dependencies.
#
[base]
pkg = pypfilt
wheels = {homedir}/.cache/pip/wheels
pytest = {envbindir}/py.test --cov={envsitepackagesdir}/{[base]pkg} --capture=no
install_command=pip install -f {[base]wheels} {opts} {packages}
deps =
wheel>=0.29
pytest
pytest-cov
hypothesis>=3.7
#
# Define environment-specific settings.
#
# * The documentation builds are performed in the ./doc directory.
# * The documentation builds depend on Sphinx and associated packages.
# * The test cases depend on the testing packages defined in [base].
# * Python 3.5 tests issue errors about comparing bytes and strings (-bb).
#
[testenv]
changedir =
docs: doc
deps =
test: {[base]deps}
docs: sphinx>=1.4
docs: sphinx-rtd-theme>=0.1.9
docs: sphinxcontrib-inlinesyntaxhighlight>=0.2
commands =
py27-test: {envpython} {[base]pytest} {posargs}
py35-test: {envpython} -bb {[base]pytest} {posargs}
docs: sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html