ImportError using nose, no ImportError using raw unittest ?

Posted by southof40 on Stack Overflow See other posts from Stack Overflow or by southof40
Published on 2010-05-10T01:19:30Z Indexed on 2010/05/10 1:28 UTC
Read the original article Hit count: 544

Filed under:
|
|

I get an ImportError when running my unittests using Nose and I don't when I just run it standalone. All files referred to here may be seen at http://gist.github.com/395541# .

If I run the test script, importTest-Test.py, directly I get this output:

C:\usr\x\data\src\Python\mmm>python importTest-Test.py
In mmdb
In BusinessLogic
[]
.
----------------------------------------------------------------------
Ran 1 test in 0.001s

If I allow Nose to run it I get an error :

C:\usr\x\data\src\Python\mmm>nosetests.exe
E
======================================================================
ERROR: Failure: ImportError (No module named mmdb.DataAccess.AttemptDB)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\bin\installed\python2.6\lib\site-packages\nose-0.11.3-py2.6.egg\nose\loader.py", line 382, in loadTestsFromName
    addr.filename, addr.module)
  File "c:\bin\installed\python2.6\lib\site-packages\nose-0.11.3-py2.6.egg\nose\importer.py", line 39, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "c:\bin\installed\python2.6\lib\site-packages\nose-0.11.3-py2.6.egg\nose\importer.py", line 86, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "C:\usr\x\data\src\Python\mmm\importtest-Test.py", line 2, in <module>
    import importtest
  File "C:\usr\x\data\src\Python\mmm\importtest.py", line 1, in <module>
    from mmdb.BusinessLogic.AttemptManager import AttemptManager
  File "C:\usr\x\data\src\Python\mmm\mmdb\BusinessLogic\AttemptManager.py", line 1, in <module>
    from mmdb.DataAccess.AttemptDB import AttemptDB
ImportError: No module named mmdb.DataAccess.AttemptDB

----------------------------------------------------------------------
Ran 1 test in 0.002s

FAILED (errors=1)

The files involved in the package which nose is having difficulties with are in the following structure - some may be seen here http://gist.github.com/395541# .:

mmm\importtest-Test.py
mmm\importtest.py
mmm\mmdb
mmm\__init__.py
mmm\mmdb\BusinessLogic
mmm\mmdb\BusinessObject
mmm\mmdb\DataAccess
mmm\mmdb\__init__.py
mmm\mmdb\BusinessLogic\AttemptManager.py
mmm\mmdb\BusinessLogic\Collections
mmm\mmdb\BusinessLogic\__init__.py
mmm\mmdb\BusinessLogic\Collections\__init__.py
mmm\mmdb\BusinessObject\__init__.py
mmm\mmdb\DataAccess\AttemptDB.py
mmm\mmdb\DataAccess\__init__.py

This is happening on Win32 / Python 2.6 / Nose 0.11.3 .

I'd be grateful for any help.

thanks.

© Stack Overflow or respective owner

Related posts about python

Related posts about nose