Commits

holger krekel committed 45ab873
  • Participants
  • Parent commits 66749bc
  • Branches trunk

Comments (0)

Files changed (4)

 
 (c) Holger Krekel and others, 2004-2010
 """
-__version__ = version = "2.0.0.dev1"
+__version__ = "2.0.0.dev1"
 
 from py import _apipkg
 
         'textwrap'        : '._compat.dep_textwrap:textwrap',
         'subprocess'      : '._compat.dep_subprocess:subprocess',
     },
-))
+))

py/_path/local.py

                     self._prependsyspath(self.dirpath())
                 modname = self.purebasename
             mod = __import__(modname, None, None, ['__doc__'])
+            if self.basename == "__init__.py":
+                return mod # we don't check anything as we might
+                       # we in a namespace package ... too icky to check
             modfile = mod.__file__
             if modfile[-4:] in ('.pyc', '.pyo'):
                 modfile = modfile[:-1]
             if modfile.endswith(os.path.sep + "__init__.py"):
                 if self.basename != "__init__.py":
                     modfile = modfile[:-12]
+
             if not self.samefile(modfile):
                 raise self.ImportMismatchError(modname, modfile, self)
             return mod
         long_description = long_description,
         install_requires=['py>=1.3.9', ], # force newer py version which removes 'py' namespace
         #                                  # so we can occupy it
-        version= '2.0.0.dev1',
+        version='2.0.0.dev2',
         url='http://pylib.org',
         license='MIT license',
         platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
 
 if __name__ == '__main__':
     main()
-

testing/path/test_local.py

         assert orig == p
         assert issubclass(pseudopath.ImportMismatchError, ImportError)
 
+    def test_issue131_pyimport_on__init__(self, tmpdir):
+        # __init__.py files may be namespace packages, and thus the
+        # __file__ of an imported module may not be ourselves
+        # see issue
+        p1 = tmpdir.ensure("proja", "__init__.py")
+        p2 = tmpdir.ensure("sub", "proja", "__init__.py")
+        m1 = p1.pyimport()
+        m2 = p2.pyimport()
+        assert m1 == m2
+
 def test_pypkgdir(tmpdir):
     pkg = tmpdir.ensure('pkg1', dir=1)
     pkg.ensure("__init__.py")