You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pytest is the most popular testing framework in Python. I want to enhance its error logging, just like #76.
Here's my code:
importbetter_exceptionsfrompytestimportExceptionInfodefpatch(exc_info, exprinfo):
tb=exc_info[2]
# max_traceback_limit(tb)# traceback is staring from the root cause. deal it in the end.# rich.print(tb)# breakpoint()cls=ExceptionInfotextlist=better_exceptions.format_exception(
exc=exc_info[0], value=exc_info[1], tb=tb)
# textlist = better_exceptions.format_exception(*exc_info)text="".join(textlist)
keyword="in pytest_pyfunc_call"text=text.split("\n")
last_index=-20fori, tinenumerate(text):
ifkeywordint:
last_index=ibreaktext=text[last_index:]
text="\n".join(text)
print()
print(text) # great. this could be the hook.returncls(exc_info, text, _ispytest=True)
ExceptionInfo.from_exc_info=patch
This code will not replace the original formatting of exceptions in Pytest, just print its own error info side by side. I want to know if there are better ways to do so, also builtin hook supports?
The text was updated successfully, but these errors were encountered:
Pytest is the most popular testing framework in Python. I want to enhance its error logging, just like #76.
Here's my code:
This code will not replace the original formatting of exceptions in Pytest, just print its own error info side by side. I want to know if there are better ways to do so, also builtin hook supports?
The text was updated successfully, but these errors were encountered: