Skip to content

Hide traceback lines from library #52

@ROpdebee

Description

@ROpdebee

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions