-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Description
importorskip attempts to perform an import and then raises Skipped exception via skip function which has __tracebackhide__
attribute set to True.
This caused the exception in test_importorskip when I added handling of chained exceptions(#1467):
_______________________ test_importorskip _______________________
monkeypatch = <_pytest.monkeypatch.monkeypatch object at 0x110a1e2e8>
def test_importorskip(monkeypatch):
importorskip = pytest.importorskip
def f():
importorskip("asdlkj")
try:
sys = importorskip("sys") # noqa
assert sys == py.std.sys
#path = pytest.importorskip("os.path")
#assert path == py.std.os.path
excinfo = pytest.raises(pytest.skip.Exception, f)
> path = py.path.local(excinfo.getrepr().reprcrash.path)
testing/test_runner.py:502:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_pytest/_code/code.py:418: in getrepr
return fmt.repr_excinfo(self)
_pytest/_code/code.py:609: in repr_excinfo
reprtraceback = self.repr_traceback(excinfo)
_pytest/_code/code.py:585: in repr_traceback
last = traceback[-1]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = [], key = -1
def __getitem__(self, key):
> val = super(Traceback, self).__getitem__(key)
E IndexError: list index out of range
_pytest/_code/code.py:289: IndexError
The exception is raised because the traceback entry in the original exception is filtered (because of __tracebackhide__
local variable set to True
).
Metadata
Metadata
Assignees
Labels
No labels