[Numpy-discussion] How to run unittests at build time?

Robert Kern robert.kern@gmail....
Wed Sep 21 16:09:46 CDT 2011


On Wed, Sep 21, 2011 at 15:56, Sandro Tosi <morph@debian.org> wrote:
> Hello,
> at (Debian) package build time, it would be really important to run
> the tests suite, but I'm not getting how to do that.

The way that nosetests imports packages in order to navigate to find
test files is a bit wonky. It doesn't respect proper package
semantics. Or perhaps just the behavior that we see from normal
imports. In particular, many of our __init__.py files do something
like this:

  from foo import **
  __all__ = []
  __all__.extend(foo.__all__)

The reason why this normally works is that once you do any kind of
import from the foo submodule, it gets added to the namespace of the
package's actual module object. However, nosetests is manually
"importing" the __init__.py file and bypassing the normal import
mechanism, so it misses some of these semantics.

I suspect nosetests may be doing something different to load files
that have been installed into site-packages rather than other
locations. Unfortunately, I don't know a workaround other than to
modify all of our __init__.py file to do more explicit imports rather
than relying on the implicit behavior of the full Python import
mechanism.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco


More information about the NumPy-Discussion mailing list