don't hide an ImportError when importing a plugin produces one.
fixes issue375.
This commit is contained in:
parent
31576fac61
commit
dde0a81677
|
@ -5,6 +5,9 @@ Unreleased
|
||||||
since the unittest compat enhancements allow
|
since the unittest compat enhancements allow
|
||||||
trial to handle it on its own
|
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
|
- fix issue380 by making --resultlog only rely on longrepr instead
|
||||||
of the "reprcrash" attribute which only exists sometimes.
|
of the "reprcrash" attribute which only exists sometimes.
|
||||||
|
|
||||||
|
|
|
@ -263,19 +263,10 @@ def importplugin(importspec):
|
||||||
name = importspec
|
name = importspec
|
||||||
try:
|
try:
|
||||||
mod = "_pytest." + name
|
mod = "_pytest." + name
|
||||||
#print >>sys.stderr, "tryimport", mod
|
|
||||||
__import__(mod)
|
__import__(mod)
|
||||||
return sys.modules[mod]
|
return sys.modules[mod]
|
||||||
except ImportError:
|
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)
|
__import__(importspec)
|
||||||
except ImportError:
|
|
||||||
raise ImportError(importspec)
|
|
||||||
return sys.modules[importspec]
|
return sys.modules[importspec]
|
||||||
|
|
||||||
class MultiCall:
|
class MultiCall:
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import pytest, py, os
|
import pytest, py, os
|
||||||
from _pytest.core import PluginManager
|
from _pytest.core import * # noqa
|
||||||
from _pytest.core import MultiCall, HookRelay, varnames
|
|
||||||
from _pytest.config import get_plugin_manager
|
from _pytest.config import get_plugin_manager
|
||||||
|
|
||||||
|
|
||||||
|
@ -652,3 +651,11 @@ def test_default_markers(testdir):
|
||||||
"*tryfirst*first*",
|
"*tryfirst*first*",
|
||||||
"*trylast*last*",
|
"*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)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue