[IPython-dev] Running tests

Fernando Perez fperez.net at gmail.com
Mon Jan 11 15:27:34 EST 2010

Hi Jorgen,

On Mon, Jan 11, 2010 at 11:36 AM, Jörgen Stenarson
<jorgen.stenarson at bostream.nu> wrote:
> I often run IPython/testing/iptest.py as a script but this is not possible
> now due to a relative import:
> C:\python\external\ipython-perez\IPython>python testing\iptest.py
> Traceback (most recent call last):
>  File "testing\iptest.py", line 39, in <module>
>    from . import globalipapp
> ValueError: Attempted relative import in non-package

Argh, yes.  This is unfortunately only fixed for 2.6:


We might just add that boilerplate

if __name__ == "__main__" and __package__ is None:
    __package__ = "expected.package.name"

protected by a version check, so your approach continues to work.

I've started using absolute imports because they will become default
eventually, and they do provide some other benefits (see pep if
curious).  For the most part they are innocuous, but this little
glitch will need addressing, thanks.  Now tracked:


> Using my usual trick of just adding a py extension to iptest in
> python26/Scripts so I can use iptest at the prompt I get a similar failure
> when trying to run all tests. It looks like iptest tries to launch a new
> iptest for every test group.
> /Jörgen
> C:\python\external\ipython-perez\IPython>iptest
> *****************************************************************************
> IPython test group: IPython.utils
> python: can't open file
> 'C:\Python26\lib\site-packages\IPython\scripts\iptest':
> [Errno 2] No such file or directory

Mmmh, if you can track the problem, let me know. Otherwise I'll try to
get to a Windows VM as soon as possible, but it may take me a couple
of days.

Question: had you installed ipython, or where you running from a  source tree?



More information about the IPython-dev mailing list