[TIP] How do I get nose to add the cwd to sys.path?

jason pellerin jpellerin at gmail.com
Sat Nov 15 10:52:41 PST 2008

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. ;)


More information about the testing-in-python mailing list