[TIP] How do I get nose to add the cwd to sys.path?
daryl.spitzer at gmail.com
Thu Nov 13 14:41:06 PST 2008
That did the trick. I went with:
from os.path import dirname, abspath
But shouldn't that be unnecessary?
On Thu, Nov 13, 2008 at 2:33 PM, Grig Gheorghiu
<gheorghe_gheorghiu at yahoo.com> wrote:
> --- On Thu, 11/13/08, Daryl Spitzer <daryl.spitzer at gmail.com> wrote:
>> When I run `nosetests` it finds the tests in the .py files
>> in tests/,
>> but I get an import error in the tests when they try to
>> import the
>> module they're testing (which is in the parent
>> directory of the tests
>> in "tests"). I've tried `nosetests -w .`
>> (and other variants) but I
>> get the same import errors.
> I do that 'by hand'. In the __init__.py file in the tests directory I have these 2 lines:
> import os, sys
> sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
More information about the testing-in-python