[Biopython-dev] Deprecating Bio.ParserSupport, Bio.Blast.NCBIStandalone
Peter Cock
p.j.a.cock at googlemail.com
Fri Feb 1 12:14:49 UTC 2013
>Wibowo Arindrarto <w.arindrarto at gmail.com> wrote:
>> Just to be clear, we are:
>>
>> * changing all module's doctest file path to use relative
>> paths (with
>> respect to the module's location),
>> * replacing the run_doctest() import with a simpler doctest
>> import and
>> `doctest.testmod()` in each module having this doctest
>> * resorting to setUp and tearDown in the DocTestSuite in
>> `run_tests.py` so that each module / submodule can find
>> their test
>> files
>> * and refactoring all string functions in Bio._utils to
>> Bio.Phylo and
>> Bio.SearchIO, so that we can remove Bio._utils,
>>
>> right?
>>
>> I'd be happy to give this a shot if everyone feels the same
>> :).
>>
On Fri, Feb 1, 2013 at 11:23 AM, Michiel de Hoon <mjldehoon at yahoo.com> wrote:
> Hi Bow,
>
> Yes, that is correct.
> Responding to Peter's email: Peter, do you agree with this approach?
>
> Best,
> -Michiel.
No. I think we have misunderstood each other on the doctest
discussion :(
If we keep the test files under Tests/ (and I think that is best)
then for example look at this doctest in Bio/SeqRecord.py
>>> from Bio import SeqIO
>>> record = SeqIO.read(open("Fasta/sweetpea.nu"),"fasta")
>>> len(record)
309
That is currently written to assume it is run from the Tests/
folder. If we write this assuming is it in the Bio/ folder where
the Python file SeqRecord.py lives, it becomes:
>>> from Bio import SeqIO
>>> record = SeqIO.read(open("../Tests/Fasta/sweetpea.nu"),"fasta")
>>> len(record)
309
I think a beginner would find that more confusing. It is also longer
and we already have trouble with some lines exceeding 80 chars.
Ideally there would be a nice way for doctests to specify the folder,
and then we could use a simple filename like "sweetpea.nu" with
no directories at all. But I don't think that is possible without us
making the testing infrastructure even more complicated.
--
If we want to get rid of Bio._utils.run_doctest() (and the whole of
the file Bio/_utils.py) then I would prefer reverting to the old situation
prior to adding the Bio._utils.run_doctest() helper function.
If the repetitive code snippets to run the doctests of a module are a
problem it can be shortened to something less flexible, for example
in Bio/SeqRecord.py could use something very short like this:
if __name__ == "__main__":
assert os.path.isfile("Fasta/sweetpea.nu"), "Run from Tests/ folder"
import doctest
doctest.testmod(verbose=2)
Or, as I suggested before, we can remove these development
convenience hooks completely?
--
On the subject of the string functions in Bio/_utils.py, I have no
objection to moving them back under Bio.SearchIO and/or
Bio.Phylo - which has advantages in terms of modularity (a
good thing for preventing accidental side effects).
Regards,
Peter
More information about the Biopython-dev
mailing list