Testing with toxΒΆ
The pypfilt testing suite uses the pytest
framework, and uses the tox automation tool
to run the tests under 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.
#
# Configuration file for tox, used to automate test activities.
#
# https://tox.readthedocs.io/en/latest/
#
# This configuration file defines the following test environments:
#
# py38-test: Run the test cases in ./tests/ using Python 3.8.
# py38-docs: Build the package documentation using Python 3.8.
#
# To perform each of these test activities, run:
#
# tox
#
[tox]
envlist = py38-{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
test_paths = {envsitepackagesdir}/{[base]pkg} tests/ doc/
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 tests issue errors about comparing bytes and strings (-bb).
#
[testenv]
setenv =
# Ignore ImportMismatchErrors when running doctests.
# See https://github.com/pytest-dev/pytest/issues/2042 for details.
test: PY_IGNORE_IMPORTMISMATCH = 1
# Do not attempt to import sphinx_rtd_theme when searching for doctests in
# doc/conf.py.
test: READTHEDOCS = True
changedir =
docs: doc
deps =
test: {[base]deps}
test: matplotlib>=1.5
docs: sphinx>=1.4
docs: sphinx-rtd-theme>=0.1.9
docs: sphinxcontrib-inlinesyntaxhighlight>=0.2
commands =
py38-test: {envpython} -bb {[base]pytest} {[base]test_paths}
docs: sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html
[pytest]
addopts = --doctest-modules --doctest-glob='*.rst'