[Numpy-discussion] Doctests for extensions/cython code

Fernando Perez fperez.net@gmail....
Sun Jul 13 01:32:35 CDT 2008

Hi all (esp. Alan McIntyre),

I'm attaching two little tarballs with a set of tools that may come in
handy for testing numpy:

- plugin.tgz contains a Nose plugin that works around various issues
in the python stdlib, in nose and in cython, to enable the testing of
doctests embedded in extension modules.  I must note that this code
also provides a second plugin that is ipython-aware, and the code as
shipped is NOT yet acceptable for public use in numpy, because it
insantiates a full ipython on import.  But I wrote this primarily for
ipython, so for us that's OK.

For numpy, we obviously must first remove all the ipython-specific
code from there.  The two plugins are separated,  so it's perfectly
doable, I just ran out of time.  I'm putting it here in the hopes that
it will be useful to Alan, who can strip it of the ipython
dependencies and start using it in the numpy tests.

The one thing I didn't figure out yet was how to load the plugin from
within a python script (instead of  doing it at the command line via
'nosetests --extdoctests').  But this should be trivial, it's just a
matter of  finding the right call in nose, and you may already know

- primes.tgz is the cython 'primes' example, souped up with trivial
code that contains some extra doctests both in python and in extension
code.  It's just meant to serve as a test for the above plugin (I also
used it to provide a self-contained cython example complete with a
setup.py file in a seminar, so it can be useful as a starter example
for some).

I don't know if today's numpy.test() picks up doctests in extension
modules (if it does, I'd like to know how).  I suspect the answer is
not, but if we are to encourage better examples that serve as
doctests, then actdually testing them would be good.

I hope this helps in that regard.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: plugin.tgz
Type: application/x-gzip
Size: 10149 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080712/edf9e774/attachment.tgz 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: primes.tgz
Type: application/x-gzip
Size: 2609 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080712/edf9e774/attachment-0001.tgz 

More information about the Numpy-discussion mailing list