Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

PyTest print STDOUT and STDERR using -s

  • -s
  • -q
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