In python unittests, the unit test captures stdout so prints only occur after the test is finished. I want a way to forcefully bypass these and log specific messages to the console without completely disabling this functionality. How can I do that?
Asked
Active
Viewed 74 times
0
-
Are you using pytest? – frankfalse Apr 07 '23 at 07:09
-
See this answer: https://stackoverflow.com/a/56049216/3717691 – Jeppe Apr 07 '23 at 07:09
-
@frankfalse I am just running the code in PyCharm, but it's basically just QoL during long tests so I can actually see if something is happening – Henry C Apr 07 '23 at 07:27
-
@Jeppe I have attempted to add a buffer as described there while leaving out the ontextlib.redirect_stdout, but it doesn't appear to work :/ – Henry C Apr 07 '23 at 07:27
-
@Henry C My only suggestion in this moment is: if you use pytest exists the option `-s` which is used to suppress the `Captured stdout call`, but I don't know if it is useful for you. Please add code. – frankfalse Apr 07 '23 at 07:35
-
If your problem is related to PyCharm, perhaps check this issue: https://youtrack.jetbrains.com/issue/PY-22505 – Jeppe Apr 10 '23 at 07:32