PyTest print STDOUT and STDERR using -s
import sys
import appprint
def test_hello():
print("hello testing")
print("stderr during testing", file=sys.stderr)
def test_add():
assert appprint.add(2, 3) == 5
Using also -q makes it easier to see the printed text.
$ pytest -s -q test_stdout_stderr.py
hello testing
stderr during testing
.Adding 2 to 3
.
2 passed in 0.01 seconds