Python Nose Import Error -


I can not find the module under its test script in the file structure to identify the module. I have set the most straightforward example that shows the problem. I explain it down

This package file structure is:

  ./__init__.py ./foo.py ./tests ./__init__.py. Foo.py includes:  
  def dumb_true (): return true  

test / test_foo.py includes:

  import foo def test_foo (): foo.dumb_true ()  

Both init . The file is empty

If I run nosetests -vv in the main directory (where is foo.py) I get:

  Failure: ImportError (a module named Fu) ... error ===================================== == ============================== Error: Failure: Import Error ------------ ------------------------------------------------ Tracebacks (most recent call final): File "/usr/lib/python/site-packages/nose-0.11.1-py2.6.egg/nose/loader.py", line 379, loadtest addr in the fnname. Filename, addr.module) File "/usr/lib/python/site-packages/nose-0.11.1-py2.6" .gg / nose / importer.py ", line 39, aa InformPath Returns Self Imported Fremdir (DIR_Path, FQNA) file "/usr/lib/python/site-packages/nose-0.11.1-py2.6.egg/nose/importer.py", line 86, importFromDir mod = load_module "/home/user/nose_testing/tests/test_foo.py" in line (part_fqname, fh, filename, desc), line 1, & lt; module & gt; import foo importError: there is no module named Fu --------------------------------------- ----------- ----------------- 0.002s test run FAILED (errors = 1)  

When I run through trial / directory I am getting a single error. According to the lettering and I found that the nose should link all the original packages with the path as well as the directory from where it is called, but it does not seem like this in my case.

I am running Ubuntu 8.04 with Python 2.6.2. I manually created and installed the nose (not with setup_tools) if it counts

You found a __init __.py in your top level directory. This package creates if you delete it, then your nosetests should work.

If you do not delete it, you will have to change your import to import dir.foo , where dir Is the name of your directory.


Comments