[Biopython-dev] How to add unit tests

Peter Cock p.j.a.cock at googlemail.com
Tue Jul 24 09:33:14 UTC 2012


On Tue, Jul 24, 2012 at 8:34 AM, Kai Blin
<kai.blin at biotech.uni-tuebingen.de> wrote:
> Hi folks,
>
> I've sent Wibowo a patch implementing a parser for yet another format.
> He asked for some tests, and I'm happy to provide them. Or at least I
> would be if I was clear on how to add them. Some modules seem to use
> doctests, some seem to have something home-grown. Where would I put
> the sequence files to parse during the tests?
>
> Hope you can shed some light on this,
> Kai

There is a whole chapter on our testing setup in the Tutorial,
http://biopython.org/DIST/docs/tutorial/Tutorial.html
http://biopython.org/DIST/docs/tutorial/Tutorial.pdf

In short:

All the recent unit tests use the standard library unittest library.
Older unit tests use a home grown print-and-compare approach
where we have a copy of the expected output as a file on disk.

Input files (of reasonable size, with providence information if
possible - i.e. where they came from) are under the Tests
folder in sub-directories by type or module. In the case of
hmmer2, put them somewhere based on where Bow is putting
his hmmer3 files.

We also use doctests (in the code) for short illustrative examples
with no external dependencies. You do use doctest style embedded
examples which do have dependencies (e.g. network access),
but we don't run them as unit tests to avoid test failures.

We also use doctests in the LaTeX source of the tutorial, run
via test_Tutorial.py - again only things without dependencies.

Peter



More information about the Biopython-dev mailing list