On Thu, May 20, 2010 at 13:12 +0200, Hans Meine wrote:
> On Thursday 20 May 2010 12:49:31 holger krekel wrote:
> > On Thu, May 20, 2010 at 12:43 +0200, Hans Meine wrote:
> > > [...] py.test fails with
> > > 
> > > E           ImportError: No module named something.test_foo
> > > 
> > > [...]
> > > 
> > > Obviously, this is a bug that should be fixed, but I would already happy
> > > if you could tell me a workaround (i.e. different invocation of py.test,
> > > without changing the directory name of course).
> > 
> > The error message is a bit obscure but scrolling a bit up you see
> > that py.test tries to import  'io.something.test_foo'
> 
> Can I circumvent this?  (IIRC, for instance nosetests differentiates between 
> full filenames and importable module names.)

Could you elaborate on nose's logic a bit?
 
> > - i.e. you have created a package 'io' and that overlaps with the standard
> > library's 'io' package.
> 
> Ah, bad.  But I won't change that now, after using the name myself for 
> several 
> years already.  Who needs stdlib's io anyway.. ;-p

Hehe :) However, it only works as long as no pluguin and no code you are using
depends on the standard 'io' module.  py.test itself uses a fallback in case it
can't "from io import StringIO" but in general a user package named 'io'
will lead to breakage, latest when using Python3. 
 
> Another workaround is to prepend my main package directory to PYTHONPATH 
> (tested, works -> fine).

You could also try to not have __init__.py files in test directories -
as long as all tests have unique names that's fine (and py.test should
warn you if there is a conflict). 

> Thanks for the explanation,
>   Hans

have fun,
holger

> PS: No need to CC me anymore, the list turned out to be subscribers-only. :-/

P.S.: yeah, sorry. otherwise a lot of spam-sorting would be needed to let
the occassional post through.
_______________________________________________
py-dev mailing list
py-dev@codespeak.net
http://codespeak.net/mailman/listinfo/py-dev

Reply via email to