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

--tb=native should exclude non-user frames #13023

Open
belm0 opened this issue Dec 3, 2024 · 1 comment
Open

--tb=native should exclude non-user frames #13023

belm0 opened this issue Dec 3, 2024 · 1 comment
Labels
status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity

Comments

@belm0
Copy link

belm0 commented Dec 3, 2024

Like --tb=long/short, --tb=native should only show user frame frames.

Users of "native" want the same scope of information, just in the native traceback format. I believe it's straightforward to prune the traceback object before formatting.

currently:

___________________________________ test_foo ___________________________________
Traceback (most recent call last):
  File "/.../lib/python3.11/site-packages/_pytest/runner.py", line 340, in from_call
    result: Optional[TResult] = func()
                                ^^^^^^
  File "/.../lib/python3.11/site-packages/_pytest/runner.py", line 240, in <lambda>
    lambda: runtest_hook(item=item, **kwds), when=when, reraise=reraise
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../lib/python3.11/site-packages/pluggy/_hooks.py", line 501, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../lib/python3.11/site-packages/pluggy/_manager.py", line 119, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../lib/python3.11/site-packages/pluggy/_callers.py", line 181, in _multicall
    return outcome.get_result()
           ^^^^^^^^^^^^^^^^^^^^
  File "/.../lib/python3.11/site-packages/pluggy/_result.py", line 99, in get_result
    raise exc.with_traceback(exc.__traceback__)
  File "/.../lib/python3.11/site-packages/pluggy/_callers.py", line 166, in _multicall
    teardown.throw(outcome._exception)
  File "/.../lib/python3.11/site-packages/_pytest/threadexception.py", line 87, in pytest_runtest_call
    yield from thread_exception_runtest_hook()
  File "/.../lib/python3.11/site-packages/_pytest/threadexception.py", line 63, in thread_exception_runtest_hook
    yield
  File "/.../lib/python3.11/site-packages/pluggy/_callers.py", line 166, in _multicall
    teardown.throw(outcome._exception)
  File "/.../lib/python3.11/site-packages/_pytest/unraisableexception.py", line 90, in pytest_runtest_call
    yield from unraisable_exception_runtest_hook()
  File "/.../lib/python3.11/site-packages/_pytest/unraisableexception.py", line 65, in unraisable_exception_runtest_hook
    yield
  File "/.../lib/python3.11/site-packages/pluggy/_callers.py", line 166, in _multicall
    teardown.throw(outcome._exception)
  File "/.../lib/python3.11/site-packages/_pytest/logging.py", line 849, in pytest_runtest_call
    yield from self._runtest_for(item, "call")
  File "/.../lib/python3.11/site-packages/_pytest/logging.py", line 832, in _runtest_for
    yield
  File "/.../lib/python3.11/site-packages/pluggy/_callers.py", line 166, in _multicall
    teardown.throw(outcome._exception)
  File "/.../lib/python3.11/site-packages/_pytest/capture.py", line 883, in pytest_runtest_call
    return (yield)
            ^^^^^
  File "/.../lib/python3.11/site-packages/pluggy/_callers.py", line 166, in _multicall
    teardown.throw(outcome._exception)
  File "/.../lib/python3.11/site-packages/_pytest/skipping.py", line 256, in pytest_runtest_call
    return (yield)
            ^^^^^
  File "/.../lib/python3.11/site-packages/pluggy/_callers.py", line 102, in _multicall
    res = hook_impl.function(*args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../lib/python3.11/site-packages/_pytest/runner.py", line 182, in pytest_runtest_call
    raise e
  File "/.../lib/python3.11/site-packages/_pytest/runner.py", line 172, in pytest_runtest_call
    item.runtest()
  File "/.../lib/python3.11/site-packages/_pytest/python.py", line 1772, in runtest
    self.ihook.pytest_pyfunc_call(pyfuncitem=self)
  File "/.../lib/python3.11/site-packages/pluggy/_hooks.py", line 501, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../lib/python3.11/site-packages/pluggy/_manager.py", line 119, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../lib/python3.11/site-packages/pluggy/_callers.py", line 138, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "/.../lib/python3.11/site-packages/pluggy/_callers.py", line 102, in _multicall
    res = hook_impl.function(*args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../lib/python3.11/site-packages/_pytest/python.py", line 195, in pytest_pyfunc_call
    result = testfunction(**testargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/.../pytest_tb_test.py", line 6, in test_foo
    bar()
  File "/home/.../pytest_tb_test.py", line 2, in bar
    raise ValueError('oops')
ValueError: oops

wanted:

___________________________________ test_foo ___________________________________
Traceback (most recent call last):
  File "/home/.../pytest_tb_test.py", line 6, in test_foo
    bar()
  File "/home/.../pytest_tb_test.py", line 2, in bar
    raise ValueError('oops')
ValueError: oops
@The-Compiler
Copy link
Member

The whole point of --tb=native is to turn off any traceback processing, which is very useful to get the actual traceback if there are any bugs in that processing (e.g. frames are being hidden that shouldn't be) — so I'm -1 to this, as it defeats the whole purpose.

What's your use-case here, and how does your desired output differ from what --tb=short already gives you?

@The-Compiler The-Compiler added the status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity label Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity
Projects
None yet
Development

No branches or pull requests

2 participants