nose-devs/nose — Issue #162: [patch] Mysterious import problems with namespace packages 
Author: jpellerin
Created: 2011-12-14 16:02:21+00:00
State: open

I ran across this with Paste -- it shares 'paste' as a namespace package with PasteDeploy and
PasteScript.

nose's importer deletes modules from sys.modules that don't appear to match the targeted test's
parent modules. The logic it uses to determine if modules match (Importer.sameModule) is
flawed for namespace packages: it only compares a module's __path__[0] when it should be
comparing against every entry of its __path__

nose has no issue if for example only Paste is installed. Once PasteDeploy or Script are also
installed (additional entries in sys.modules['paste'].__path__), sameModule becomes confused
and causes the 'paste' package to be deleted from sys.modules in Importer.importFromDir when
it shouldn't be.

Symptoms of this problem are modules mysteriously being unable to import other modules when
they should be able to. See the attached test case for an example, I've also included a fix

Google Code Info:
Issue #: 164
Author: pjenvey%...@gtempaccount.com
Created On: 2008-02-28T05:09:14.000Z
Closed On: 2008-03-26T01:51:20.000Z