Skip to content
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

Hide traceback lines from library #52

Open
ROpdebee opened this issue Jun 14, 2019 · 0 comments
Open

Hide traceback lines from library #52

ROpdebee opened this issue Jun 14, 2019 · 0 comments

Comments

@ROpdebee
Copy link

ROpdebee commented Jun 14, 2019

Currently the traceback output goes something like this (with pytest --tb=native):

Traceback (most recent call last):
  <stuff in my project>
  <4+ lines inside grappa>
AssertionError: Oops! Something went wrong!
  <grappa custom formatting>

It would be nice if the lines originating from grappa internals could be hidden from the traceback output. pytest has __tracebackhide__ which can be set on a whole module IIRC, but that won't have any effect with --tb=native.

Now, the extent to which this is possible, is probably limited. sys.excepthook might be an option, but should be opt-in as it may override other custom traceback formatters. Also, AFAIK
pytest ignores this hook completely and prints out their exceptions on their own. Maybe catch the exception at the top-level of the library, adjust the traceback to remove the library frames, and re-raise? Or a pytest formatter plugin to complement the excepthook?

sgissinger added a commit to sgissinger/grappa that referenced this issue Nov 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant