ntg
ntg

Reputation: 14145

How to debug using stdout during Pytest execution

I am trying to debug a feature of a test (that runs on pytest) I am setting a debug point and stop there (using Pycharm) However, I cannot debug efficiently the code because my stdout and stderr are redirected since this is a pytest. I tried restoring stdout from sys.__stdout__ but sys.stdout = sys.__stdout__ did not work.

Is there any way to restore stdout in order to debug?

This is not a duplicate of python-pytest-capturing-stdout-always-fails, capturing std is not failing in my case, it's captured at a location that is not really helping me to debug...

Upvotes: 4

Views: 623

Answers (1)

DemetriOS
DemetriOS

Reputation: 191

Utilize the -s option while running pytest. As shown here: https://docs.pytest.org/en/latest/capture.html.
The -s option disables all capturing of stdout.

Upvotes: 3

Related Questions