Copy over name and path attributes to the re-raised exception
This commit is contained in:
parent
7a186df271
commit
3ea987ef9d
|
@ -384,7 +384,12 @@ class PytestPluginManager(PluginManager):
|
||||||
try:
|
try:
|
||||||
__import__(importspec)
|
__import__(importspec)
|
||||||
except ImportError as e:
|
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:
|
except Exception as e:
|
||||||
import pytest
|
import pytest
|
||||||
if not hasattr(pytest, 'skip') or not isinstance(e, pytest.skip.Exception):
|
if not hasattr(pytest, 'skip') or not isinstance(e, pytest.skip.Exception):
|
||||||
|
|
Loading…
Reference in New Issue