3

Usint pytest on Pycharm, I have some long tests for which I want to be able to manually monitor progress of.
Things like neural network training - I want to see loss and progress bar.

Running the same code from a regular function like main() gives console output fine.

Running through a pytest test doesn't put anything to console until the test is over.


How to make pytest still output to console in Pycharm?

I found this answer and tried -s and --capture=tee-sys which do basically nothing.


Feb 03 2021 Just asked on pycharm's forum.

Gulzar
  • 23,452
  • 27
  • 113
  • 201

1 Answers1

3

add -s to your Additional Arguments in the Run/Debug Configuration.

This will disable the default pytest stdout/stderr capturing.

MrBean Bremen
  • 14,916
  • 3
  • 26
  • 46
Lior Cohen
  • 5,570
  • 2
  • 14
  • 30
  • More detail: I am trying to run a pytorch-lightning test, and some of the tests are long. I have to wait to the end of the run to see the result. `-s` doesn't work. Easily reproducible by downloading their open source https://github.com/PyTorchLightning/pytorch-lightning and running a test. – Gulzar Feb 03 '21 at 12:11
  • 1
    `-s` doesn't work for me. I still have to wait for the test to end if I want to see the output in the run window. – Gulzar Feb 03 '21 at 12:41
  • This works for me in pycharm 2022 – WestCoastProjects Dec 21 '22 at 05:50