pytest-dev / pytest

The pytest framework makes it easy to write small tests, yet scales to support complex functional testing
https://pytest.org
MIT License
12.18k stars 2.69k forks source link

Terminal reporter doesn't print #8973

Open gaborbernat opened 3 years ago

gaborbernat commented 3 years ago
# 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.

$ 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:

$ 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.).

RonnyPfannschmidt commented 3 years ago

@gaborbernat extra fun, without flush it works on pytest 6.x+

gaborbernat commented 3 years ago

Eh what 😂

RonnyPfannschmidt commented 3 years ago

@gaborbernat i identified the core issue - terminalwriter for some reason is not using a dup-ed stdout, so it is subject to capture intervention,l i will work out a bugfix later on

gaborbernat commented 3 years ago

Great 👍

gaborbernat commented 2 years ago

@RonnyPfannschmidt has this been addressed?

RonnyPfannschmidt commented 2 years ago

No

emileakbarzadeh commented 3 weeks ago

Any updates?