[Biopython-dev] Rethinking Biopython's testing framework

Giovanni Marco Dall'Olio dalloliogm at gmail.com
Tue Dec 30 13:53:34 UTC 2008


On Tue, Dec 30, 2008 at 11:06 AM, Michiel de Hoon <mjldehoon at yahoo.com> wrote:
>
>
>
> --- On Sat, 12/27/08, Giovanni Marco Dall'Olio <dalloliogm at gmail.com> wrote:
>> Basically, we will have to move every test in
>> functions/classes with
>> names beginning with 'test_'. To be more precise,
>> they should match
>> the regular expression '(?:^|[b_.-])[Tt]est' (it is
>> also possible to
>> coustomize this regex).
>>
>> So, if a test now is it like this:
>>
>> if __name__ == '__main__':
>>     seq = Seq('sadasda')
>>     assert seq.tostring() == 'sadasda'
>>
>> we will have to refactor it like this:
>>
>> def _test():
>>     """test description"""
>>     seq = Seq('sadasda')
>>     assert seq.tostring() == 'sadasda'
>>
>> if __name__ == '__main__':
>>     _test()   # this is optional
>
> Probably I don't quite understand how nose works, but if we refactor the code in this way, is that sufficient to enable users to use nose if they want to? If so, it may be possible to write the test scripts in a nose-compliant way as a courtesy to nose users. The only problem I can see with this is that it will be difficult to maintain. Basically every new test will have to be written in this nose-compliant way, and users are likely to be unaware of this.


Why do you find it difficult?
You just have to rename every test to make sure that its name starts
or end with 'test_'. That's all.
If you want to reorganize biopython's testing framework, this is a
good thing to do anyway.

In particular, every test function/class/script name should match the
regular expression '(?:^|[b_.-])[Tt]est' (it can be customized).
Unittest modules and doctest will be recognized, too.
Note that nose already works if you run it over biopython's cvs; but
since I am not familiar with biopython's code, I am not sure it
recognizes every test.

Ehm, this example that I put won't work with the default settings :/
it expected 'test_module' or something like this (anyway, the regex
can be customized).


> --Michiel
>
>
>
>



-- 

My blog on bioinformatics (now in English): http://bioinfoblog.it



More information about the Biopython-dev mailing list