[Biopython-dev] How to add unit tests
Wibowo Arindrarto
w.arindrarto at gmail.com
Tue Jul 24 04:11:15 EDT 2012
Hi Kai,
Indeed there seem to be different kinds of testing in the Biopython
tests suite. I can't really answer for test suites other than
SearchIO, so I'll try to explain what I have in mind for SearchIO. In
general, SearchIO has been using the unittest module, with roughly one
test file being tested by one test function. Here are the 'consensus'
that I'm using:
1. All test files are stored in a folder in the 'Tests' folder
according to the program name. For example, HMMER files are all stored
in the HMMER folder.
2. In each of those program-specific folder, there is a README file
listing the test files and what they are.
3. The naming scheme of the test files may differ slightly between
each program, but they are always consistent in the same program.
Taking another example from the HMMER file, you can see that they are
named like so: 'format_version_program_number.out'. So the first test
file for the text output format from hmmpfam version 2.11 would be
named "text_211_hmmpfam_001.out".
4. As for the contents of these files, it is basically up to you. I
myself try to cover at least cases where there are single and multiple
queries, and try to make them as short as possible (although sometimes
it's not really that short).
4. The python test file itself are named like so:
'test_SearchIO_{format}.py'. This test file only tests parsing and/or
reading-related code, and maybe some format-specific tests. If one
program has several formats that differ slightly, they are grouped in
one test file named 'test_SearchIO_{program}.py' Tests for indexing
and writing are written in 'test_SearchIO_index.py' and
'test_SearchIO_write.py' for now. There's also a file called
'search_tests_common.py' that tests for equality between two different
QueryResult objects (all their attributes and the items they contain),
but so far this is only used in indexing and writing tests.
5. As for the doctests, they are meant to use the files in each
program-specific folder as well. You are free to add extra files that
showcases the important features of your parser; a file that's not
used by the actual unittest suite. However, as you can see, the
doctests are very little at the moment, as I am also still in the
process of writing them. For now, I'm prioritizing the unittests
first.
I hope that helps :), and thanks again for the patch!
regards,
Bow
On Tue, Jul 24, 2012 at 9:34 AM, Kai Blin
<kai.blin at biotech.uni-tuebingen.de> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> 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
>
> - --
> Dipl.-Inform. Kai Blin kai.blin at biotech.uni-tuebingen.de
> Institute for Microbiology and Infection Medicine
> Division of Microbiology/Biotechnology
> Eberhard-Karls-Universität Tübingen
> Auf der Morgenstelle 28 Phone : ++49 7071 29-78841
> D-72076 Tübingen Fax : ++49 7071 29-5979
> Germany
> Homepage: http://www.mikrobio.uni-tuebingen.de/ag_wohlleben
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iQEcBAEBAgAGBQJQDlAXAAoJEKM5lwBiwTTPI7AH/RWsVXeymP2r6WuDeyzCL+oe
> S9OEqy7hQGc89ktd1HLn8LVid4baA5f31zPXaPsBdjwFfZT/8l3khjXp3JhOOsQJ
> wsKsqS985MiswkI0ZzTc598LhOt0oVz2cCPynLFFpj8K9f9OL5PdFKm9owS1urmP
> 919TBaRX7AWN/qyv3vCztMwvxrMYPz6hKw78oHikJP+i6rtEKYVyVYrvtqBBn0E4
> 7J/Hfkh+aqAgYR1YlWYCrNlHGM6xJpXmwwIPZp1C1Fgb2sFPsXcHLEQi9KydB7SK
> m+fosoow40BJbIerBYyUNGOcAkW5yuObLk99UYcYq26LEhUjDcpqNM8C2OtW4NI=
> =pu0a
> -----END PGP SIGNATURE-----
> _______________________________________________
> Biopython-dev mailing list
> Biopython-dev at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biopython-dev
More information about the Biopython-dev
mailing list