Copy over name and path attributes to the re-raised exception

This commit is contained in:
Bruno Oliveira 2016-03-10 18:13:59 -03:00
parent 7a186df271
commit 3ea987ef9d
1 changed files with 6 additions and 1 deletions

View File

@ -384,7 +384,12 @@ class PytestPluginManager(PluginManager):
try:
__import__(importspec)
except ImportError as e:
raise ImportError('Error importing plugin "%s": %s' % (modname, e))
new_exc = ImportError('Error importing plugin "%s": %s' % (modname, e))
# copy over name and path attributes
for attr in ('name', 'path'):
if hasattr(e, attr):
setattr(new_exc, attr, getattr(e, attr))
raise new_exc
except Exception as e:
import pytest
if not hasattr(pytest, 'skip') or not isinstance(e, pytest.skip.Exception):