Hi,

I managed to achieve the results using only the pytest_report_teststatus. I
don't know if it is the best solution, but it now works as expected.

The code is available at https://github.com/felipecrp/pytest-pyspec

Regards,
Felipe

On Fri, Feb 24, 2023 at 11:17 AM Felipe Curty <felipe...@gmail.com> wrote:

> Hello,
>
> I have been using pytest for a while and want to write a plugin to change
> its output.
>
> I would like to achieve the following output:
>
> From:
>
> test/test_sample.py .
>
> To
>
> test/test_sample.py
> A House
>  with two floors
>    has stairs                [Passed]
>
> I intend to use pytest_runtest_logreport in the setup phase to print the "A
> House with two floors has stairs". And to use pytest_report_teststatus to
> print the [Passed]. However, in `pytest_runtest_logreport`, I do not have
> access to TerminalReporter. Hence, apparently, the only alternative is to
> use the `print` command. Is there any problem using print instead of
> Terminal Reporter?
>
> I checked that some plugins already change the output, but they do this by
> changing the TerminalReporter class. For instance, pydev-it creates a
> subclass of the TerminalReporter (which is now a @final class and should
> not be extended), and pydev-spec patches some methods of the
> TerminalReporter.
>
> Regards,
> Felipe
>
>
_______________________________________________
pytest-dev mailing list
pytest-dev@python.org
https://mail.python.org/mailman/listinfo/pytest-dev

Reply via email to