#8973·pytest

Terminal reporter doesn't print

Author: gaborbernatCreated Aug 3, 2021Updated Sep 24, 2026
Labelstype: bugtopic: reportingtype: regression
python
# test_a.py
def test_foo(request):
    reporter = request.config.pluginmanager.getplugin("terminalreporter")
    reporter.ensure_newline()
    reporter.write("magic", flush=True)

If you run the above file through pytest nothing is written on the output.

bash
$ pytest . 

platform linux -- Python 3.9.6, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /tmp/workdir
plugins: print-0.3.0
collected 1 item

test_a.py .   [100%]

Though I'd expect something like:

bash
$ pytest . 

platform linux -- Python 3.9.6, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /tmp/workdir
plugins: print-0.3.0
collected 1 item

test_a.py
   magic .
   [100%]

Note if you remove the flush we do get the message printed, but without respecting the ensure newline (instead you get test_a.py magic.).