[IPython-user] [Pytables-users] Failing tests with 2.0rc1

Fernando Perez fperez.net@gmail....
Mon Aug 13 07:25:14 CDT 2007

On 8/13/07, Francesc Altet <faltet@carabos.com> wrote:

> I've run the tests from inside of IPython and yes, the issue seems to be fixed
> now (at least on the Linux side).  Many thanks!


> Just a little quirk though.  When I run the tests in command line mode, i.e.:
> $ PYTHONPATH=. ipython tables/tests/test_all.py
> the tests finish correctly, but IPython doesn't apparently think so:

> --> 806         sys.exit(not result.wasSuccessful())
>     807
>     808 main = TestProgram
> SystemExit: False
> WARNING: Failure executing file: <tables/tests/test_all.py>

Well, you're raising SystemExit, so IPython correctly detects an
exception was raised.

> Python 2.5.1 (r251:54863, May  2 2007, 16:56:35)
> Type "copyright", "credits" or "license" for more information.
> IPython 0.8.2.svn.r2601 -- An enhanced Interactive Python.
> ?       -> Introduction to IPython's features.
> %magic  -> Information about IPython's 'magic' % functions.
> help    -> Python's own help system.
> object? -> Details about 'object'. ?object also works, ?? prints more.
> In [1]:
> I've checked that test_all.py returns a value of 0 when it exits (i.e. $?
> variable has a 0 value, as it should).  Perhaps IPython is (wrongly) assuming
> that returning a 0 is a failure instead of success?

There's a difference between the system exit status of a child process
($?) being zero and the fact that an exception was raised *inside* a
Python process, which sys.exit() unconditionally does.  In fact, if
you were to run that code in a normal python shell, you'd just get
dumped out to the prompt:

maqroll[~]> cat foo.py
import sys
maqroll[~]> python
Python 2.5.1 (r251:54863, May  2 2007, 16:56:35)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> execfile('foo.py')
maqroll[~]>   # oops, out of the interpeter!

IPython has a special trap on SystemExit to precisely prevent this
from happening.

What you want to use when running code that raises SystemExit is the
special '-e' flag to %run, which makes %run ignore the SystemExit
exception altogether:

In [1]: run foo
SystemExit                                Traceback (most recent call last)

/home/fperez/foo.py in <module>()
----> 2 import sys
      3 sys.exit(0)

SystemExit: 0
WARNING: Failure executing file: <foo.py>

In [2]: run -e foo

I introduced that flag precisely for the purpose of running unittests
inside ipython.

I guess I could modify the SystemExit trap to check for 0 as a value
and simply print a short message in that case... For code that uses
sys.exit() correctly to signal exit status, this would be nicer.  OK,
I think I'll do that.

> And another small thing (the last one for today, I promise ;).  I've installed
> IPython from the nightly built eggs that you are providing recently (very
> good job! BTW, how are you generating the Windows binary automatically?  I'd
> like to do the same with PyTables), and a couple of errors appear during the
> installation:

python setup.py bdist_wininst

However, note that this only works if your program has *zero*
extension code, since there's no cross-compilation going on at all.
For ipython that's OK, but it won't work for pytables, which requires
extension code to be compiled.  What they did was to literally bundle
the entire .exe as a inside of distutils:

maqroll[command]> pwd
maqroll[command]> ls *.exe
wininst-6.exe  wininst-7.1.exe

> File "/usr/lib/python2.5/site-packages/ipython-0.8.2.svn.r2601-py2.5.egg/IPython/Extensions/foo.py",
> line 2
>     >>> range(5, 10)
>      ^
> SyntaxError: invalid syntax

silly accident, that file was a temporary test that shouldn't have been there.

> File "/usr/lib/python2.5/site-packages/ipython-0.8.2.svn.r2601-py2.5.egg/share/doc/ipython-0.8.2.svn.r2601/examples/extension.py",
> line 6
>     def ${name}_f(self, arg):
>         ^
> SyntaxError: invalid syntax

Yes, this is ugly but should be harmless.  I don't actually use eggs
myself, so I don't know if one can tell them to not byte-compile that
stuff (which is NOT in a package directory, so I don't know why it
wants to compile it in the first place).  Maybe Ville, who does use
eggs, might know how to make that error go away.

> I've checked that these errors are non-fatal (my IPython installation seems to
> work just fine), but I thought that it would be worth to keep you informed.
> Thanks again for delivering, improving and maintaining such a poweful
> interpreter!

My pleasure :) And thanks for pytables, which recently has proven
great for a project at work!



More information about the IPython-user mailing list