examples/pytest/test_stdout_stderr.py
import sys

def test_hello():
    print("hello testing")
    print("stderr during testing", file=sys.stderr)
    assert True
$ pytest -s -q test_stdout_stderr.py
hello testing
stderr during testing
.
1 passed in 0.01 seconds