[Biopython-dev] Fwd: Unit tests

Gavin E. Crooks gec at compbio.berkeley.edu
Tue Nov 6 16:09:59 EST 2001


I have been working on updating the SCOP module. Now, I am a big fan of
unit tests, and I find myself writing unit tests for almost everything. Not
simple regression tests, but proper unit tests using the PyUnit framework.

I am having problems understanding how to integrate my tests into biopythons
framework. Most of the things in biopython/tests appear to be regression tests
with a PyUnit coating.

After looking around a bit, I found this unit test description from Zope.

http://cvs.zope.org/Zope/doc/UNITTEST.txt?rev=1.2&content-type=text/vnd.viewcvs-markup

Not only does this document clearly describe what a unit test should be, it also
describes how the Zope tests are organized. Here is the important bit.

>Writing Unit Tests For The Zope Core
>
> If you're writing core code, you probably don't need to listen to
>  any more of this.  :-) The rules for writing tests for Zope core
>  code are simple:
>
>  - The testing code should make use of PyUnit
>     (/lib/python/unittest.py).  Instructions for using PyUnit are
>     available at http://pyunit.sourceforge.net.
>
>  - Tests must be placed in a "tests" subdirectory of the package or
>     directory in which the core code you're testing lives.
>
>   - Test modules should be named something which represents the
>     functionality they test, and should begin with the prefix "test."
>     E.g., a test module for BTree should be named testBTree.py.
>
>   - An individual test module should take no longer than 60 seconds
>     to complete.

This is very similar to one of the two main ways of organizing Junit tests in
the java community.

I think this would be a good way to organize biopythons unit tests. Thoughts?
Comments?

Gavin Crooks

gec at compbio.berkeley.edu
http://threeplusone.com/



On Tue, 06 Nov 2001, you wrote:
> No objections here.  Brad can probably give you better insight about 
> the regression tests, since he did the coding for it.
> 
> Jeff
> 
> 
> >Perhaps we should move this conversation to biopython-dev?
> >
> >On Tue, 06 Nov 2001, you wrote:
> >>  >Could you explain what the relation of Tests/UnitTest is to thre
> >>  >rest of the tests? Its all very confusing.
> >>
> >>  Yeah.  We're using python-style regression testing, which means that
> >>  a test suite is just a python script whose name begins with "test_"
> >>  and outputs a bunch of text.  Doing a regression test means running
> >>  the script and checking it against previous output.
> >>
> >>  We're using unittest.py under the hood to do the checking.  Thus,
> >>  we're not taking advantage of all the nice features that it provides.
> >>  While it would be worth considering moving the whole system over, I'm
> >>  not sure anybody wants to go back and rewrite all the old tests.
> >>
> >>
> >>
> >>  >And is there a particular version of python we should be programming
> >>  >to? I just loaded up the latest version, and assumed that anything
> >>  >avaliable would be avaliable. Perhaps I should downgrade?
> >>
> >>  We're currently only requiring Python 2.0, but perhaps it's time to
> >>  reevaluate that.
> >>
> >>  Jeff
-------------------------------------------------------



More information about the Biopython-dev mailing list