make inspect.getsource work for standalone py.test by implementing a get_source method on our DictImporter.
--HG-- branch : trunk
This commit is contained in:
parent
a42d9eb9f6
commit
1103f2ad62
|
@ -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)
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue