Does nosetests
treat directories with certain names differently? Is a src
directory special?
If I have a project whose source directory is named src
, nosetests
seems to work fine. However, if the directory is named anything else, nosetests
reports a bunch of import errors.
Here's what I did:
run tests
~/src$ nosetests .. ---------------------------------------------------------------------- Ran 2 tests in 0.001s OK
rename directory
~/src$ cd .. ~/$ mv src/ src2
rerun tests
~/$ cd src2 ~/src2$ nosetests E ====================================================================== ERROR: Failure: ImportError (No module named **whatever**) ---------------------------------------------------------------------- Traceback (most recent call last): ... etc. ... import **whatever** ImportError: No module named **whatever** ---------------------------------------------------------------------- Ran 1 test in 0.001s FAILED (errors=1)
I wasn't able to find anything in the docs about this.
Example: with this directory structure:
.
|-- a
| |-- b.py
| `-- __init__.py
|-- __init__.py
`-- test
|-- a
| |-- __init__.py
| `-- testb.py
`-- __init__.py
all __init__.py
files are empty, the contents of a/b.py
are:
y = 3
and of test/a/testb.py
:
import a.b
import unittest as u
class TestB(u.TestCase):
def test1(self):
self.assertTrue(True)
def test2(self):
self.assertTrue(False)
I can reliably reproduce this problem. Running nosetests -V
gives:
nosetests version 1.2.1