Testing
pyANI-plus
is currently tested using the pytest
package to ensure that it functions correctly and remains stable across updates.
Test directory structure
The tests/
subdirectory in the pyANI-plus
repository contains all test files, including input data, expected results, and test outputs.
- Input data for tests are provided in
tests/fixtures
directory. Thisfixtures
directory contains a variety of test sets, including sequence data and intermediate files, intended for use and testing with pyANI-plus. The current test sets include:viral_example
: Three phage genomes that share similar regions, resulting in aligned regions. These viral genomes are the main test set due to the short runtime of the methods.bacterial_example
: Four bacterial genomes previously used for testing the legacypyANI
. This test set only being used in the test suite for the faster methods like fastANI and sourmash.bad_alignments
: Two highly divergent phage genomes with no shared regions, resulting in no alignments. This test set ensures thatpyANI-plus
correctly detects and handles such comparisons, which are recorded in the database asNULL
.tools
: Mock tools designed for version testing of third-party tools. It also includes examples of faulty tools that are either not executable or do not provide version information.
Each test set (apart from tools
) includes the follwoing subdirectories: - intermediates
: Contains intermediate files expected to be generated by the ANI methods (e.g., .filter
and .delta
files for ANIm
). - matrices
: Includes the expected TSV matrix outputs for each ANI method implemented.
- Test output is written to temporary files that are automatically deleted after execution.
We welcome contributions from the community! If you would like to write new tests for pyANI-plus
, please ensure your test data and operations follow this structure.
Running tests
To run tests with pyest
, change directory to the root of the pyANI-plus
repository, and invoke a pyest
command.
Run all tests locally
To run all tests locally on your machine, issue the following command from the repository root:
pytest -v
Alternatively, if you wish to run tests and generate a coverage report, you can do so with the following command from the repository root:
python -m pytest -n auto --cov-report=html --cov=pyani_plus -v && open htmlcov/index.html
Run individual tests
Tests are organised in files with filenames matching the patter test_*.py
. We write tests using functions, following the pytest style, as descibed in the pytest documentation.
For example, to run all ANIm-related tests, we can run:
pytest tests/test_anim.py
To run a specific test, such as the one that checks if the .delta files are parsed correctly, we can use the following command:
pytest tests/test_anim.py::test_delta_parsing