
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 it.
- 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.
Cheers
f

On Sun, Jul 13, 2008 at 2:32 AM, Fernando Perez fperez.net@gmail.com wrote:
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.
Thanks! I'll see if I can work this in soon.
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 it.
If you're constructing a TestProgram, you can pass in a list of plugin instances. If I recall correctly, you have to pass in every plugin that you might want to use, even if they're builtin (I suppose the given list replaces the internal plugin list somewhere, I haven't traced it). So if you leave the doctest plugin out of this list, for example, the "--with-doctest" will cause an error. (This is all from memory, though, so take it with a grain of salt)
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'd be surprised if it did; I'll have a look.
I hope this helps in that regard.
Certainly, thanks for doing it!
participants (2)
-
Alan McIntyre
-
Fernando Perez