use non-hacky dynamic package import method

This commit is contained in:
Benjamin Peterson 2012-04-27 17:51:50 -04:00
parent 1c817aa7bd
commit 64c7c1be15
2 changed files with 6 additions and 3 deletions

View File

@ -321,13 +321,15 @@ def importplugin(importspec):
name = importspec
try:
mod = "_pytest." + name
return __import__(mod, None, None, '__doc__')
__import__(mod)
return sys.modules[mod]
except ImportError:
#e = py.std.sys.exc_info()[1]
#if str(e).find(name) == -1:
# raise
pass #
return __import__(importspec, None, None, '__doc__')
__import__(importspec)
return sys.modules[importspec]
class MultiCall:
""" execute a call into multiple python functions/methods. """

View File

@ -416,9 +416,10 @@ def importorskip(modname, minversion=None):
__tracebackhide__ = True
compile(modname, '', 'eval') # to catch syntaxerrors
try:
mod = __import__(modname, None, None, ['__doc__'])
__import__(modname)
except ImportError:
py.test.skip("could not import %r" %(modname,))
mod = sys.modules[modname]
if minversion is None:
return mod
verattr = getattr(mod, '__version__', None)