fix issue95 - treat a failing pytest_genscript import
as non-critical, give a hint. --HG-- branch : trunk
This commit is contained in:
parent
f552749de6
commit
c3bd29b490
|
@ -140,6 +140,13 @@ class PluginManager(object):
|
||||||
except py.test.skip.Exception:
|
except py.test.skip.Exception:
|
||||||
e = py.std.sys.exc_info()[1]
|
e = py.std.sys.exc_info()[1]
|
||||||
self._hints.append("skipped plugin %r: %s" %((modname, e.msg)))
|
self._hints.append("skipped plugin %r: %s" %((modname, e.msg)))
|
||||||
|
except ImportError:
|
||||||
|
e = py.std.sys.exc_info()[1]
|
||||||
|
if "zlib" in str(e) and modname == "pytest_genscript":
|
||||||
|
self._hints.append("skipped plugin %r: failed to import %r" %(
|
||||||
|
(modname, str(e))))
|
||||||
|
else:
|
||||||
|
raise
|
||||||
else:
|
else:
|
||||||
check_old_use(mod, modname)
|
check_old_use(mod, modname)
|
||||||
self.register(mod)
|
self.register(mod)
|
||||||
|
|
|
@ -37,3 +37,4 @@ def test_rundist(testdir, pytestconfig, standalone):
|
||||||
result.stdout.fnmatch_lines([
|
result.stdout.fnmatch_lines([
|
||||||
"*1 passed*",
|
"*1 passed*",
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
|
@ -489,3 +489,29 @@ class TestHookRelay:
|
||||||
res = mcm.hello(arg=3)
|
res = mcm.hello(arg=3)
|
||||||
assert res == 4
|
assert res == 4
|
||||||
|
|
||||||
|
def test_pluginmanager_import_error_zlib(testdir):
|
||||||
|
p = testdir.makepyfile("""
|
||||||
|
try:
|
||||||
|
import builtins
|
||||||
|
except ImportError:
|
||||||
|
import __builtin__ as builtins
|
||||||
|
oldimport = builtins.__import__
|
||||||
|
|
||||||
|
def import_(name, *args):
|
||||||
|
#print "import", name, "start"
|
||||||
|
if name == "zlib":
|
||||||
|
raise ImportError("zlib")
|
||||||
|
mod = oldimport(name, *args)
|
||||||
|
#print "import", name, "successful"
|
||||||
|
return mod
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
builtins.__import__ = import_
|
||||||
|
import py
|
||||||
|
py.test.cmdline.main(["--traceconfig"])
|
||||||
|
""")
|
||||||
|
result = testdir.runpython(p)
|
||||||
|
result.stdout.fnmatch_lines([
|
||||||
|
"*skipped plugin*genscript*import*zlib*",
|
||||||
|
])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue