[py-svn] py-trunk commit 5a401029c1d4: make inspect.getsource work for standalone py.test by implementing a get_source method on our DictImporter.
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Wed Dec 30 19:05:46 CET 2009
# HG changeset patch -- Bitbucket.org
# Project py-trunk
# URL http://bitbucket.org/hpk42/py-trunk/overview/
# User Ralf Schmitt <ralf at systemexit.de>
# Date 1262196106 -3600
# Node ID 5a401029c1d42ceecbae097e2692284913145a4e
# Parent 27f764f5693b9e7e3dfc9180c3598cf29adfc58e
make inspect.getsource work for standalone py.test by implementing a get_source method on our DictImporter.
--- a/bin-for-dist/py.test-in
+++ b/bin-for-dist/py.test-in
@@ -47,6 +47,14 @@ class DictImporter(object):
do_exec(co, module.__dict__)
return sys.modules[fullname]
+ def get_source(self, name):
+ res = self.sources.get(name)
+ if res is None:
+ res = self.sources.get(name+'.__init__')
+ return res
+
+
+
importer = DictImporter()
sys.meta_path.append(importer)
--- a/py/apipkg.py
+++ b/py/apipkg.py
@@ -17,6 +17,7 @@ def initpkg(pkgname, exportdefs):
mod.__file__ = getattr(oldmod, '__file__', None)
mod.__version__ = getattr(oldmod, '__version__', None)
mod.__path__ = getattr(oldmod, '__path__', None)
+ mod.__loader__ = getattr(oldmod, '__loader__', None)
sys.modules[pkgname] = mod
def importobj(modpath, attrname):
More information about the pytest-commit
mailing list