[SciPy-dev] tests, relative import: what's best ?

David Cournapeau david@ar.media.kyoto-u.ac...
Mon Nov 26 00:36:10 CST 2007


    I have a question regarding tests and import in numpy/scipy in 
general. When implementing tests, the package to be tested has to be 
imported, and there are two possibilities on how to do it (both are used 
in scipy). Taking an hypothetical package foo in scipy as an example:

    1 : using set_package_path /restore_path facilities of 
numpy.testing, and do a "relative" import

from foo import bar

This means that you can test the package foo without building the whole 
scipy source tree. This is for example used in scipy.linalg tests. It 
also correspond to DISTUTILS.txt doc in numpy/doc.

    2 : using set_package_path / restore_path facilities, and do a 
"absolute" import:

from scipy.foo import bar

In this case, I don't understand why set_package_path is used ? And 
also, this means that you cannot test the subpackage by itself, you need 
to install the whole scipy tree. This is for example used in 
scipy.signal tests.

Are there any advantages to 2 ? If not, would it be a good idea to 
convert every package to convention 1 ?



More information about the Scipy-dev mailing list