[TIP] tox/nosetest runs tests fine, but throws 4 ImportErrors, why?

Albert-Jan Roskam fomcl at yahoo.com
Fri Mar 14 08:23:45 PDT 2014


Hi,

I am using tox and nosetests to run my unittests. For some reason, the tests run fine, but I still get 4 identical ImportErrors (one is shown below).
If I do not set PYTHONPATH to my project path I get the same error with just nosetests. It seems that imp.find_module throws this error because the second argument
(path) is not ' deep'  enough (it is just the expanded form of ~; I used pdb with nosetest to find this out). How do I get rid of this annoying error?
I don't understand why it was working before, but it no longer does. 


Btw, this happens with Python 2.7, 3.3 and Pypy, and I am on Linux debian 3.2.0-4-amd64 #1 SMP Debian 3.2.54-2 x86_64 GNU/Linux.


======================================================================
ERROR: Failure: ImportError (No module named 'myModule')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/albertjan/nfs/Public/myModule/.tox/py33/lib/python3.3/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "/home/albertjan/nfs/Public/myModule/.tox/py33/lib/python3.3/site-packages/nose/loader.py", line 411, in loadTestsFromName
    addr.filename, addr.module)
  File "/home/albertjan/nfs/Public/myModule/.tox/py33/lib/python3.3/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File
 "/home/albertjan/nfs/Public/myModule/.tox/py33/lib/python3.3/site-packages/nose/importer.py", line 79, in importFromDir
    fh, filename, desc = find_module(part, path)
  File "/home/albertjan/nfs/Public/myModule/.tox/py33/lib/python3.3/imp.py", line 244, in find_module
    raise ImportError(_bootstrap._ERR_MSG.format(name), name=name)
ImportError: No module named 'myModule'
----------------------------------------------------------------------
Ran 66 tests in 5.044s

FAILED (SKIP=11, errors=4)
ERROR: InvocationError: '/home/albertjan/nfs/Public/myModule/.tox/py33/bin/nosetests'
___________________________________ summary ____________________________________
ERROR:   py33: commands failed


Thank you in advance!

Regards,

Albert-Jan




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a 

fresh water system, and public health, what have the Romans ever done for us?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20140314/06ee6f78/attachment-0001.htm>


More information about the testing-in-python mailing list