[Biopython-dev] External python dependencies and doctests

Peter biopython at maubp.freeserve.co.uk
Sat Feb 14 16:32:00 EST 2009


On Sat, Feb 14, 2009 at 6:47 PM, Peter <biopython at maubp.freeserve.co.uk> wrote:
> Hi all,
>
> Currently the doctest handling in run_tests.py requires some special
> cases for those modules with an optional external dependency, for
> example the Bio.Statistics.lowess doctests will only work if NumPy is
> installed.  We *could* just run all the doctests, and catch and ignore
> any import errors.  However, an import error might be a real error in
> Biopython (e.g. if something was deleted or moved).  This is therefore
> probably a bad idea.

I've been thinking about the exception idea in my previous email, and
maybe it is too complicated - it would be a hassle in the long term to
have to manually add this catch ImportError and raise missing
dependency code all over the place.

An alternative would be to catch all ImportError exceptions in
run_tests.py, and treat numpy and reportlab as special cases and skip
those tests.  Other ImportError cases would indeed be errors.  This is
basically what I suggested a while back on Bug 2524.
http://bugzilla.open-bio.org/show_bug.cgi?id=2524

Perhaps this is better - it puts the special case code in one place
only (run_test.py), meaning the our unit tests needing numpy or
reportlab don't need to do anything special about raising a missing
dependency error.  This isn't a big issue for the unit tests, but for
the doctests this is a significant benefit I think.

[The missing external dependency exception is still useful for missing
command line tools - although I'm not sure how best to cope with this
in a doctest.  See test_psw.py and test_wise.py for an example of this
- they are basically doctests with a wrapper to determine if the dnal
command line tool is installed.]

Peter


More information about the Biopython-dev mailing list