Weird import failure with "nosetests --processes=1"

Roy Smith roy at panix.com
Wed Nov 28 22:13:57 EST 2012


I've got a minimal test script:

-----------------------------
$ cat test_foo.py
import pyza.models
print pyza.models

def test_foo():
    pass
-----------------------------

pyza.models is a package.  Under normal conditions, I can import it fine:

$ python
Python 2.7.3 (default, Aug  1 2012, 05:14:39) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyza.models
>>> print pyza.models
<module 'pyza.models' from 
'/home/roy/deploy/current/pyza/models/__init__.pyc'>
>>> 

But when I run nosetests in parallel mode, the import fails in a way 
which has me baffled.  What's going on here?

$ nosetests --processes=1 -s test_foo:test_foo
<module 'pyza.models' from 
'/home/roy/deploy/current/pyza/models/__init__.pyc'>
E
======================================================================
ERROR: Failure: AttributeError ('module' object has no attribute 
'models')
----------------------------------------------------------------------
Traceback (most recent call last):
  File 
"/home/roy/production/python/local/lib/python2.7/site-packages/nose/loade
r.py", line 390, in loadTestsFromName
    addr.filename, addr.module)
  File 
"/home/roy/production/python/local/lib/python2.7/site-packages/nose/impor
ter.py", line 39, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File 
"/home/roy/production/python/local/lib/python2.7/site-packages/nose/impor
ter.py", line 86, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/roy/songza/pyza/djapi/test_foo.py", line 2, in <module>
    print pyza.models
AttributeError: 'module' object has no attribute 'models'

----------------------------------------------------------------------
Ran 1 test in 0.107s

FAILED (errors=1)



More information about the Python-list mailing list