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

@pytest.mark.skip causes AttributeError: 'tuple' object has no attribute 'reprtraceback' #30

Open
ellamental opened this issue Mar 11, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@ellamental
Copy link

Minimal reproduction:

@pytest.mark.skip("TODO")
def test_anything():
    pass

Traceback snippet:

  File "/Users/nick/.pyenv/versions/3.9.9/envs/project/lib/python3.9/site-packages/pytest_rich.py", line 338, in __rich_console__
    for entry in self.chain.reprtraceback.reprentries:
AttributeError: 'tuple' object has no attribute 'reprtraceback'

A quick fix is to update RichTerminalReporter.pytest_runtest_logreport from:

        if report.outcome != "passed":

to

        if report.outcome != "passed" and report.outcome != "skipped":

Extra environment info:

Python version: 3.9.9
Pytest version: 7.0.1
pytest-rich version: 0.1.1
@nicoddemus nicoddemus added the bug Something isn't working label Mar 11, 2022
@nicoddemus
Copy link
Owner

Thanks @nickfrez!

@jeffwright13
Copy link

jeffwright13 commented Jun 10, 2022

For completeness' sake, I will report that the same traceback occurs when a test is skipped via the inline pytest.skip designation (python 3.9.9, pytest 7.1.2, pytest-rich 0.1.1):

def test_d1_skip_inline():
    pytest.skip("Skipping this test with inline call to 'pytest.skip()'.")
Traceback (most recent call last):
  File "/Users/jwr003/coding/pytest-tui/venv/bin/pytest", line 8, in <module>
    sys.exit(console_main())
  File "/Users/jwr003/coding/pytest-tui/venv/lib/python3.9/site-packages/_pytest/config/__init__.py", line 187, in console_main
    code = main()
  File "/Users/jwr003/coding/pytest-tui/venv/lib/python3.9/site-packages/_pytest/config/__init__.py", line 164, in main
    ret: Union[ExitCode, int] = config.hook.pytest_cmdline_main(
  File "/Users/jwr003/coding/pytest-tui/venv/lib/python3.9/site-packages/pluggy/_hooks.py", line 265, in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
  File "/Users/jwr003/coding/pytest-tui/venv/lib/python3.9/site-packages/pluggy/_manager.py", line 80, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/Users/jwr003/coding/pytest-tui/venv/lib/python3.9/site-packages/pluggy/_callers.py", line 60, in _multicall
    return outcome.get_result()
  File "/Users/jwr003/coding/pytest-tui/venv/lib/python3.9/site-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/Users/jwr003/coding/pytest-tui/venv/lib/python3.9/site-packages/pluggy/_callers.py", line 39, in _multicall
    res = hook_impl.function(*args)
  File "/Users/jwr003/coding/pytest-tui/venv/lib/python3.9/site-packages/_pytest/main.py", line 315, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/Users/jwr003/coding/pytest-tui/venv/lib/python3.9/site-packages/_pytest/main.py", line 303, in wrap_session
    config.hook.pytest_sessionfinish(
  File "/Users/jwr003/coding/pytest-tui/venv/lib/python3.9/site-packages/pluggy/_hooks.py", line 265, in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
  File "/Users/jwr003/coding/pytest-tui/venv/lib/python3.9/site-packages/pluggy/_manager.py", line 80, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/Users/jwr003/coding/pytest-tui/venv/lib/python3.9/site-packages/pluggy/_callers.py", line 60, in _multicall
    return outcome.get_result()
  File "/Users/jwr003/coding/pytest-tui/venv/lib/python3.9/site-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/Users/jwr003/coding/pytest-tui/venv/lib/python3.9/site-packages/pluggy/_callers.py", line 39, in _multicall
    res = hook_impl.function(*args)
  File "/Users/jwr003/coding/pytest-tui/venv/lib/python3.9/site-packages/pytest_rich.py", line 246, in pytest_sessionfinish
    self.console.print(tb)
  File "/Users/jwr003/coding/pytest-tui/venv/lib/python3.9/site-packages/rich/console.py", line 1661, in print
    extend(render(renderable, render_options))
  File "/Users/jwr003/coding/pytest-tui/venv/lib/python3.9/site-packages/rich/console.py", line 1299, in render
    for render_output in iter_render:
  File "/Users/jwr003/coding/pytest-tui/venv/lib/python3.9/site-packages/pytest_rich.py", line 306, in __rich_console__
    self._render_chain(self.chain, options),
  File "/Users/jwr003/coding/pytest-tui/venv/lib/python3.9/site-packages/rich/console.py", line 506, in _replace
    return Group(*renderables, fit=fit)
  File "/Users/jwr003/coding/pytest-tui/venv/lib/python3.9/site-packages/pytest_rich.py", line 410, in _render_chain
    for last, entry in loop_last(chain.reprtraceback.reprentries):
AttributeError: 'tuple' object has no attribute 'reprtraceback'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants