How to See Normal Print Output During Pytest Run?

Better Stack Team
Updated on July 18, 2024

By default, pytest captures all output (print statements and logs) and displays it only if a test fails, keeping the output clean. However, you might want to see all output, even for passing tests.

To view print statements or logs during testing, use the -s option:

 
pytest -s

The -s option is shorthand for --capture=no, which disables pytest's output capture.