[Biopython-dev] [Bug 2640] Proposal: doctest for SeqRecord/biopython

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Tue Nov 4 15:44:47 UTC 2008


http://bugzilla.open-bio.org/show_bug.cgi?id=2640





------- Comment #6 from dalloliogm at gmail.com  2008-11-04 10:44 EST -------
(In reply to comment #5)
> (In reply to comment #4)
> > 
> > If you think it would be useful, I can write other doctests for other modules
> > in the following days.
> > 
> 
> I think adding more doctests would be useful, but they MUST get run by our
> existing test suite.  Otherwise they'll just be human readable documentation
> (which is still nice) but will not get regularly validated.

There are a few ways to do it, but it is not too difficult to implement.
The easiest thing is to use 'doctest.testmod' in the test files.
For example, you can add to test_SeqRecord.py the following lines:

import doctest 
from Bio import SeqRecord   # import the module, not SeqRecord.SeqRecord
print "testing with doctest..."
(failures, tests) = doctest.testmod(SeqRecord)
if failures == 0:
    print 'ok'
else:
    print 'some test has failed'

or you can launch the '_test' function in every module (see my patch), but this
would require importing doctest multiple times.
>>> SeqRecord._test()


I will write some other doctests in the following days/weeks and post them here
as patches, and you will decide.
Anyway, do you think they will make biopython's documentation nicer? Do you
like them?
Sometimes, doctests make the doc strings a bit messy, so some people don't like
them. 
But it is really a matter of how you write them.


-- 
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the Biopython-dev mailing list