don't hide an ImportError when importing a plugin produces one.

fixes issue375.
This commit is contained in:
holger krekel 2013-11-19 14:45:51 +01:00
parent 31576fac61
commit dde0a81677
3 changed files with 13 additions and 12 deletions

View File

@ -5,6 +5,9 @@ Unreleased
since the unittest compat enhancements allow
trial to handle it on its own
- don't hide an ImportError when importing a plugin produces one.
fixes issue375.
- fix issue380 by making --resultlog only rely on longrepr instead
of the "reprcrash" attribute which only exists sometimes.

View File

@ -263,19 +263,10 @@ def importplugin(importspec):
name = importspec
try:
mod = "_pytest." + name
#print >>sys.stderr, "tryimport", mod
__import__(mod)
return sys.modules[mod]
except ImportError:
#e = py.std.sys.exc_info()[1]
#if str(e).find(name) == -1:
# raise
pass #
try:
#print >>sys.stderr, "tryimport", importspec
__import__(importspec)
except ImportError:
raise ImportError(importspec)
return sys.modules[importspec]
class MultiCall:

View File

@ -1,6 +1,5 @@
import pytest, py, os
from _pytest.core import PluginManager
from _pytest.core import MultiCall, HookRelay, varnames
from _pytest.core import * # noqa
from _pytest.config import get_plugin_manager
@ -652,3 +651,11 @@ def test_default_markers(testdir):
"*tryfirst*first*",
"*trylast*last*",
])
def test_importplugin_issue375(testdir):
testdir.makepyfile(qwe="import aaaa")
with pytest.raises(ImportError) as excinfo:
importplugin("qwe")
assert "qwe" not in str(excinfo.value)
assert "aaaa" in str(excinfo.value)