[SciPy-dev] WxPython required?

Fernando Perez fperez.net at gmail.com
Sun Jan 20 20:51:11 EST 2008


On Jan 20, 2008 6:24 PM, Robert Kern <robert.kern at gmail.com> wrote:
>
> 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.

I was wondering if for things like GUI tests, we could use nosepipe:

http://pypi.python.org/pypi/nosepipe/

The issue is that even if you do have WX, GTK and Qt installed,
there's a very good chance that importing and then using more than one
of them in a single process will make something go bonk.

We could then have a double-pronged approach to this problem:

- Tests with optional dependencies start by testing for their
dependency and raising SkipTest if it's not there.  This way users
still see that they were skipped, but no harm is done.

- Tests that are potentially unsafe in-process (such as GUI ones) are
marked with a @dec.process or similar decorator, so that they *always*
get run in a separate process.

Would this work and solve the existing issues?

Cheers,

f



More information about the SciPy-Dev mailing list