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-rich doesn't play well with pytest_runtest_makereport #74

Open
mazulo opened this issue Nov 8, 2022 · 4 comments
Open

pytest-rich doesn't play well with pytest_runtest_makereport #74

mazulo opened this issue Nov 8, 2022 · 4 comments
Labels
bug Something isn't working pytest parity Bring pytest-rich up to feature parity with pytest’s built-in terminal reporter

Comments

@mazulo
Copy link

mazulo commented Nov 8, 2022

It looks like that the pytest-rich doesn't pay well with a custom pytest_runtest_makereport. I've the following example to reproduce the issue:

# conftest.py
import pytest
from _pytest.reports import TestReport


@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
    outcome = yield
    if item.config.getvalue("verbose") > 0:
        report = outcome.get_result()

        test_fn = item.obj
        docstring: str = getattr(test_fn, '__doc__')
        test_name = report.nodeid.split("::")[0]
        if docstring:
            report.nodeid = f"{docstring.strip()} <- {test_name}"
    else:
        when = call.when
        duration = call.stop - call.start
        keywords = dict([(x, 1) for x in item.keywords])
        sections = []
        default_test_report = TestReport(
            item.nodeid,
            item.location,
            keywords,
            outcome,
            None,
            when,
            sections,
            duration,
        )
        return default_test_report
# test.py
def test_one_plus_one_equals_2():
    """
    This is a test with a documentation that should show up on the pytest report
    """
    assert 1 == 1

If I ran the test with pytest test.py --verbose --rich this is what I get:

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── pytest session starts ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮│ platform linux pytest 7.2.0 python 3.10.7                                                                                                                                                                                                                                                                                                                                                                                    ││ root /home/mazulo/dev/random_code/tests                                                                                                                                                                                                                                                                                                                                                                                      │╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯Collected 1 items
⠋ [  0%] test.py
⠋ Progress       INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/_pytest/main.py", line 270, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/_pytest/main.py", line 324, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__
INTERNALERROR>     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/_pytest/main.py", line 349, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__
INTERNALERROR>     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/_pytest/runner.py", line 112, in pytest_runtest_protocol
INTERNALERROR>     runtestprotocol(item, nextitem=nextitem)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/_pytest/runner.py", line 125, in runtestprotocol
INTERNALERROR>     rep = call_and_report(item, "setup", log)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/_pytest/runner.py", line 224, in call_and_report
INTERNALERROR>     hook.pytest_runtest_logreport(report=report)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__
INTERNALERROR>     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pytest_rich.py", line 225, in pytest_runtest_logreport
INTERNALERROR>     self._update_task(report.nodeid)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pytest_rich.py", line 194, in _update_task
INTERNALERROR>     task = self.runtest_tasks_per_file[fn]
⠋ [  0%] test.py
⠋ Progress

However if I remove the --rich from there, it works just fine:

dev/random_code/tests via 🐍 v3.10.7 (tests) 
❯ pytest test.py --verbose
===================================================================================================================================================================================================== test session starts ======================================================================================================================================================================================================platform linux -- Python 3.10.7, pytest-7.2.0, pluggy-1.0.0 -- /home/mazulo/.virtualenvs/tests/bin/python
cachedir: .pytest_cache
rootdir: /home/mazulo/dev/random_code/tests
plugins: spec-3.2.0, rich-0.1.1
collected 1 item                                                                                                                                                                                                                                                                                                                                                                                                                

test.py::test_one_plus_one_equals_2
This is a test with a documentation that should show up on the pytest report <- test.py PASSED                                                                                                                                                                                                                                                                                                                           [100%] 

====================================================================================================================================================================================================== 1 passed in 0.00s =======================================================================================================================================================================================================

Something more weird happens when I use the approach outlined here: https://stackoverflow.com/a/61002385/3716354

# conftest.py

import inspect
import pytest


@pytest.hookimpl(trylast=True)
def pytest_configure(config):
    terminal_reporter = config.pluginmanager.getplugin("terminalreporter")
    config.pluginmanager.register(
        TestReportDocstringPlugin(terminal_reporter), "testreportdocstring"
    )

class TestReportDocstringPlugin:
    def __init__(self, terminal_reporter):
        self.terminal_reporter = terminal_reporter
        self.docstring = None

    @pytest.hookimpl(tryfirst=True, hookwrapper=True)
    def pytest_runtest_setup(self, item):
        self.docstring = inspect.getdoc(item.obj)
        yield

    @pytest.hookimpl(hookwrapper=True, tryfirst=True)
    def pytest_runtest_logfinish(self, nodeid: str, location):
        if self.terminal_reporter.verbosity == 0:
            yield
        else:
            if self.docstring:
                test_name = nodeid.split("::")[0]
                docstring = self.docstring.strip()
                self.terminal_reporter.write(f"\n{docstring} <- {test_name}")
            yield

This is the result of running pytest test.py -vvv --rich (actually this same error happens when running without the -vvv flag):

dev/random_code/tests via 🐍 v3.10.7 (tests) 
❯ pytest test.py -vvv --rich
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── pytest session starts ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮│ platform linux pytest 7.2.0 python 3.10.7                                                                                                                                                                                                                                                                                                                                                                                    ││ root /home/mazulo/dev/random_code/tests                                                                                                                                                                                                                                                                                                                                                                                      │╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯Collected 1 items
  [100%] test.py ✔
⠋ Progress        INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/_pytest/main.py", line 270, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/_pytest/main.py", line 324, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__
INTERNALERROR>     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/_pytest/main.py", line 349, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__
INTERNALERROR>     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/_pytest/runner.py", line 113, in pytest_runtest_protocol
INTERNALERROR>     ihook.pytest_runtest_logfinish(nodeid=item.nodeid, location=item.location)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__
INTERNALERROR>     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_callers.py", line 34, in _multicall
INTERNALERROR>     next(gen)  # first yield
INTERNALERROR>   File "/home/mazulo/dev/random_code/tests/conftest.py", line 24, in pytest_runtest_logfinish
INTERNALERROR>     if self.terminal_reporter.verbosity == 0:
  [100%] test.py ✔
⠋ Progress

For some reason it seems to get stuck at if self.terminal_reporter.verbosity == 0 what shouldn't happen since we're passing the -vvv flag. So it seems that for some reason this flag is being ignored.

@mazulo
Copy link
Author

mazulo commented Nov 8, 2022

I think that I found a workaround. Basically I'm inheriting from RichTerminalReporter and then overriding a few methods. Here follows the solution:

import inspect

import pytest
from attr import define
from pytest_rich import RichTerminalReporter
from rich.progress import Progress


@define(slots=False, hash=True)
class CustomRichTerminalReporter(RichTerminalReporter):

    @pytest.hookimpl(tryfirst=True, hookwrapper=True)
    def pytest_runtest_setup(self, item):
        self.docstring = inspect.getdoc(item.obj).strip()
        self.filename = item.config.args[0]
        yield

    def pytest_runtest_logfinish(self) -> None:
        super().pytest_runtest_logfinish()
        verbose = self.config.getoption("verbose")
        if self.docstring and verbose > 0:
            self.runtest_progress.stop()
            docstring_progress = Progress(
               "{task.description}",
            )
            docstring_task = docstring_progress.add_task("Print docstring")
            docstring_progress.start()
            docstring_progress.update(
                docstring_task,
                description=f"[bold green]{self.docstring} <- {self.filename}[/bold green]",
                visible=True,
                refresh=True,
            )
            docstring_progress.stop()



@pytest.hookimpl(trylast=True)
def pytest_configure(config):
    rich_enabled = config.getoption("rich")
    verbose = config.getoption("verbose")
    rich_terminal_reporter = config.pluginmanager.getplugin("rich-terminal-reporter")

    if rich_enabled and verbose:
        config.pluginmanager.unregister(rich_terminal_reporter)
        custom_terminal_reporter = CustomRichTerminalReporter(config)
        config.pluginmanager.register(custom_terminal_reporter, "testrichreportdocstring")

And now when I run the test with pytest test.py --rich -v this is what I get:

dev/random_code/tests via 🐍 v3.10.7 (tests) 
❯ pytest test.py --rich -v
  [100%] test.py ✔
⠋ Percent: 100%
This is a test with a documentation that should show up on the pytest report <- test.py

@joshuadavidthomas
Copy link
Collaborator

Thanks for the detailed issue report @mazulo!

It appears you're using the latest version published to PyPI. Development on the package went through a lull over the summer and has since picked back up, however a new version has not been released yet with all the recent changes.

Do you mind testing with the latest version on main and report back?

pip install git+https://github.com/nicoddemus/pytest-rich.git

(I suspect you'll still run in to the same issue.)

@joshuadavidthomas joshuadavidthomas added the bug Something isn't working label Nov 8, 2022
@joshuadavidthomas
Copy link
Collaborator

joshuadavidthomas commented Nov 9, 2022

Reference:

Note: this is just so I/someone else doesn't have to go hunting for this when working on this issue in the future

@mazulo
Copy link
Author

mazulo commented Nov 9, 2022

Hey @joshuadavidthomas thanks for the response! I was just testing it after installing the latest version on main. So for the first example where I use the pytest_runtest_makereport I'm still getting the exact same error. On the second one where I use the TestReportDocstringPlugin I got almost the same error, but now it showed some division by zero error:

random_code/tests/attempt2 via 🐍 v3.10.7 (tests)                                                                                                                                                                                                                                                                                                                                                                               ❯ pytest test.py --verbose --rich

Collected 1 items
  [100%] test.py ✔
⠋ Progress        INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/_pytest/main.py", line 270, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/_pytest/main.py", line 324, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__
INTERNALERROR>     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/_pytest/main.py", line 349, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__
INTERNALERROR>     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/_pytest/runner.py", line 113, in pytest_runtest_protocol
INTERNALERROR>     ihook.pytest_runtest_logfinish(nodeid=item.nodeid, location=item.location)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__
INTERNALERROR>     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_callers.py", line 34, in _multicall
INTERNALERROR>     next(gen)  # first yield
INTERNALERROR>   File "/home/mazulo/dev/random_code/tests/attempt2/conftest.py", line 26, in pytest_runtest_logfinish
INTERNALERROR>     if self.terminal_reporter.verbosity == 0:
  [100%] test.py ✔
⠋ Progress
Traceback (most recent call last):
  File "/home/mazulo/.virtualenvs/tests/bin/pytest", line 8, in <module>
    sys.exit(console_main())
  File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/_pytest/config/__init__.py", line 190, in console_main
    code = main()
  File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/_pytest/config/__init__.py", line 167, in main
    ret: Union[ExitCode, int] = config.hook.pytest_cmdline_main(
  File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
  File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall
    return outcome.get_result()
  File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall
    res = hook_impl.function(*args)
  File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/_pytest/main.py", line 317, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/_pytest/main.py", line 305, in wrap_session
    config.hook.pytest_sessionfinish(
  File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
  File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall
    return outcome.get_result()
  File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall
    res = hook_impl.function(*args)
  File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pytest_rich/terminal.py", line 221, in pytest_sessionfinish
    self.print_summary(error_messages)
  File "/home/mazulo/.virtualenvs/tests/lib/python3.10/site-packages/pytest_rich/terminal.py", line 272, in print_summary
    f"({100 * no_of_items / self.total_items_completed:.1f}%)",
ZeroDivisionError: division by zero

I'm still going to investigate further this error and see if I can find a solution.

@joshuadavidthomas joshuadavidthomas added the pytest parity Bring pytest-rich up to feature parity with pytest’s built-in terminal reporter label Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pytest parity Bring pytest-rich up to feature parity with pytest’s built-in terminal reporter
Projects
None yet
Development

No branches or pull requests

2 participants