[TIP] Extension module discovery questions...

Fernando Perez fperez.net at gmail.com
Tue Jun 24 17:54:35 PDT 2008


Hi all,

me again :)  Sorry if this is getting annoying but I'm a bit lost
after reading the docs and trying lots of different things.

The issue I have is exactly how to tweak nose to support the discovery
of extension modules in a package.  Consider the following toy package
'sprimes' laid out as follows:

bic128[site-packages]$ d sprimes/
/home/fperez/tmp/junk/lib64/python2.5/site-packages
total 64
-rw-r--r-- 1 fperez    14 2008-06-24 17:16 __init__.py
-rw-r--r-- 1 fperez   186 2008-06-24 17:47 __init__.pyc
-rwxr-xr-x 1 fperez 31070 2008-06-24 17:47 primes.so*
-rw-r--r-- 1 fperez   396 2008-06-20 17:45 pyprimes.py
-rw-r--r-- 1 fperez   703 2008-06-24 17:47 pyprimes.pyc

This package has a pure python module 'pyprimes' and an extension one
'primes', both of which have (identical) doctests.  With my
monkeypatched plugin, I can get the following line to work OK:

nosetests -s --with-ipdoctest --doctest-tests sprimes sprimes.primes

However, if I omit the second sprimes.primes explicit mention of the
extension module, it doesn't get loaded.  So far I've tried lots of
things: --exe, overriding wantFile, loadTestsFromModule, and lots
more.  No luck.  Basically what I want is simply to ensure that when a
package is scanned, not only its pure-python submodules are loaded,
but also its extension modules.  The fact that explicit mention of the
sprimes.primes module makes it work indicates that I must be very
close, and the actual test loading does work, but I'm stupmed on
automatic recognition.

A few notes:

- I've read http://www.somethingaboutorange.com/mrl/projects/nose/doc/selector_plugin.html
and I suspect something along those lines may work, but no luck yet.

- Explicit listing of extension modules is not a viable solution,
since in large packages there may be tons of those.  After all, nose
is for test discovery :)


Any help would be very much appreciated (all this will end up publicly
available in ipython and/or numpy).

Cheers,

f



More information about the testing-in-python mailing list