diff --git a/CHANGELOG b/CHANGELOG index 8f78c5e75..f87174e31 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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. diff --git a/_pytest/core.py b/_pytest/core.py index a23e74c27..f6edb3317 100644 --- a/_pytest/core.py +++ b/_pytest/core.py @@ -263,20 +263,11 @@ 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] + return sys.modules[importspec] class MultiCall: """ execute a call into multiple python functions/methods. """ diff --git a/testing/test_core.py b/testing/test_core.py index f52bed16b..4c102e21f 100644 --- a/testing/test_core.py +++ b/testing/test_core.py @@ -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) +