Hi Jason, all,
On Sat, Nov 15, 2008 at 13:52 -0500, jason pellerin wrote:
> On Fri, Nov 14, 2008 at 6:42 PM, Kumar McMillan
> <kumar.mcmillan at gmail.com> wrote:
> > On Thu, Nov 13, 2008 at 4:27 PM, Daryl Spitzer <daryl.spitzer at gmail.com> wrote:
> >> Here's what the directory structure looks like:
>> >> I'm running `nosetests` from the foo directory.
>> [ and 'import bar' doesn't work ]
>> > I'd suggest bringing this up. I'm curious what Jason's explanation is.
>> Basically, python says that absolute imports are preferred, and if you
> run nosetests from inside a package (which is not really the right
> thing to do anyway) they won't work unless nose figures out that it's
> inside of that package and adds the package root to sys.path. I guess
> it would be possible to also add cwd in that case -- it hasn't been
> done that way so far because nobody has asked for it, and I don't use
> relative imports or run nose inside of packages myself. ;)
For larger test suites i find it practical to do structures like
mypkg/
subdir1/
mod1.py
testing/...
subdir2/
testing/...
and run tests while modifying codes in subdirs. E.g. In projects
like pypy with some >10000 tests i often want to run tests
in subdirectories and find this very useful.
FWIW, i think nosetests and py.test adding the pkg root
to sys.path is quite enough, adding CWD would cause confusion
easily.
holger
--
collaborative expert contracting: http://merlinux.eu
PyPy Python/Compiler tool chain: http://codespeak.net/pypy
pylib py.test/greenlets/svn APIs: http://pylib.org