We are currently writing tests formatted for the pytest package, for testing
Test directory structure¶
All tests, supporting input and target data, are to be found in the
tests/ subdirectory of the
- Input data for tests is located under the
tests/test_inputdirectory, in subdirectories named for the general operation that is being tested.
- Target data (known correct values) for tests is located under the
tests/test_targetsdirectory, in subdirectories named for the general operation being tested.
- Test output is written to the
tests/test_outputdirectory, in subdirectories named for the general operation being tested.
If you wish to write new tests for
pyani, we ask that your test data and operations conform to this structure
tests/test_failing_data directory contains data that is known to cause problems for
pyani in that at least two of the input genomes have no appreciable sequence identity.
To run tests with
nosetests, change directory to the root of the
pyani repository, and invoke a
Run all tests locally¶
To run all tests locally on your machine, issue the following command from the repository root:
This will cause
nose to run all tests under the
Run individual tests¶
Tests are grouped in files with filenames that match
test_*.py. We aim to write tests as classes that subclass
unittest.TestCase, as described in the nosetests documentation. An example of this style can be found in the
tests/test_anim.py test file.
This style allows us to run tests at several levels of granularity, specifying all tests (see above), all tests within a module (e.g.
test_anim.py), or all tests within a class in that test file.
For example, to run all ANIm-related tests, we can issue:
nosetests -v tests/test_anim.py
To run all tests of
nucmer command line generation, we can specify a single class within that file using the command:
nosetests -v tests/test_anim.py:TestNUCmerCmdline
And to test only “multiple command generation” we can issue the following:
nosetests -v tests/test_anim.py:TestNUCmerCmdline.test_multi_cmd_generation