views:

104

answers:

1

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.

A: 

By default, nose manipulates the PYTHONPATH it uses. You might try turning off this behavior using the -P switch.

Vicki Laidler
Thank you very much for your response, I appreciate it. Unfortunately when I do "nosetests.exe -P" the output is the same as before
southof40