[Biopython-dev] Deprecating Bio.ParserSupport, Bio.Blast.NCBIStandalone
Peter Cock
p.j.a.cock at googlemail.com
Wed Jan 30 03:52:24 EST 2013
On Wed, Jan 30, 2013 at 2:29 AM, Michiel de Hoon <mjldehoon at yahoo.com> wrote:
> Hi Bow,
>
> Thanks for the explanation.
>
>> Indeed, the doctests functions are two simple small
>> functions to make it easier to run doctests. The first
>> one looks up the test directory (our Tests directory) and
>> the second one simply executes the doctest.
>
> The point of looking up the test directory is to find the
> example input files, right?
Yes. Most of the code is working out where our Test
directory is, without that it is just two lines:
import doctest
doctest.testmod()
> Have a look at Bio/Align/Applications/_Mafft.py.
> Its doctest uses the complete path to the example input file:
>
> https://github.com/biopython/biopython/commit/32a6beb1e039fa614398a7dee1c031466e8e42ed#Bio/Align/Applications/_Mafft.py
>
> I like this solution better, since it's more straightforward, it doesn't
> need a new module, and also allows the user to run the example
> without having to figure out where the input file is located.
That's a special case - the file being referred to isn't used
other than to print out a command line string. So it is fine.
The doctests we're talking about typically are for parsing,
and they need to find the file. In order to run via the main
test suite (run_tests.py) we can assume we are in the
Biopython Tests folder and therefore use relative paths.
Those relative paths won't work if trying to run the doctests
via the __name__ trick, thus the path magic which seemed
sensible to put in one place only.
We can of course remove these __name__ trick conveniences,
they are only intended to make life easier for us developers
when editing the doctests of a module. But I think it is worth
having as a private function somewhere in the code base.
Regards,
Peter
More information about the Biopython-dev
mailing list