[SciPy-dev] WxPython required?

Robert Kern robert.kern@gmail....
Sun Jan 20 19:24:35 CST 2008

Matthew Brett wrote:
> Hi,
>>> Upon installing wxpython this error disappears, does this mean scipy
>>> depends on wxpython now?
>>  There are various approaches to
>> solve this (different test levels comes to mind, the decorator
>> approach to performance tests seen on this list as well).  The default
>> test level certainly shouldn't call this test, though.
> This prompts me to ask for advice on what to do in this kind of situation.
> When I ported the tests to nose, there were a couple of tests that
> errored due to failed dependencies, on umfpack, and PIL.   I just
> decorated the tests with an import-time check for the dependency, so
> they cannot be run without umfpack and PIL respectively, for example
> misc/tests/test_pilutil.py
> try:
>     import PIL.Image
> except ImportError:
>     _have_PIL = False
> else:
>     _have_PIL = True
>     import scipy.misc.pilutil as pilutil
> TestCase.__test__ = _have_PIL
> I guess the options are:
> Completely disable tests with absent optional dependencies (as above)
> Add such tests at the 'full' testing level with a decorator specific
> for optional dependencies, like @optdeps
> Don't run these tests with standard test levels, just allow them to be run with:
>>>> module.test('optdeps') or nosetests -A optdeps /path/to/module
> Preferences anyone?

One thing to keep in mind is that trying to import wx is not always a safe thing 
to do. On some Linux machines, I have ssh'ed into them without a local X server. 
Trying to import wx on them caused the process to exit immediately; and 
ImportError was not raised.

I'm happy to try to import PIL and have nose skip the tests if PIL is not found; 
however, this approach cannot be safely extended to wx. You might want to raise 
SkipTest instead of assigning TestCase.__test__=False, though. That tells the 
user that a test is being skipped and gives them a command line option to force 
nosetests to run the test anyways.

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 Scipy-dev mailing list