-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
INTERNALERROR with __tracebackhide__ and empty traceback #905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
its a pylib bug, by default anything above the test function is cut off, now if you in addition make it filter out the test function, then it helplessly has to resign at the empty traceback this is a missed condition in py.code |
Should someone report the issue in |
Ok the bug isn't related to pytest.mark.parametrize, I update the title. A more simple test to reproduce de bug is: def test():
__tracebackhide__ = True
assert False |
Thanks @philpep |
we want to merge py.code into py.test since a while now, so i'm ambivalent about it |
Here is a workaround i used to print the test body on Python3 (which should work on python2) (see #1493). @pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
if call.excinfo:
traceback = call.excinfo.traceback
item._prunetraceback(call.excinfo)
if len(call.excinfo.traceback) > 0:
call.excinfo.traceback = traceback
else:
# Fake frame containing the test
fakef = lambda: None
fakef.f_back = None
fakef.f_code = item.function.__code__
fakef.f_locals = item.funcargs
fakef.f_globals = item.function.__globals__
fakef.f_lineno = fakef.f_code.co_firstlineno
# Fake traceback with the fake exception at the last line of the test
faketb = lambda: None
faketb.tb_frame = fakef
faketb.tb_lineno = fakef.f_lineno
faketb.tb_lineno += len(inspect.getsourcelines(fakef.f_code)[0]) - 1 # Last line of the function
faketb.tb_next = None
call.excinfo.traceback.__init__(faketb)
yield Considering that py.code doesn't have access to the tests, i had to provide a fake traceback so it wouldn't see the difference and still produce an output. |
Fixed already. 😁 |
Hi,
I don't known if it's a py or a pytest related bug, but i didn't find the project page for py so I submit the issue here.
Consider this test:
The test fail as expected but not as expected :)
Same issue on 2.7.2 and on master branch (0b83b40)
Thanks
The text was updated successfully, but these errors were encountered: