Capturing of stdout fails #9916
-
I am trying to write tests for a function that eventually writes to The test I have written is thus: from cppstream import cout
def test_cout(capsys):
# with capsys.disabled():
cout << "Hello World!" # eventually calls sys.stdout.write
# cout.stream.flush() # explicitly flush
cap = capsys.readouterr()
assert cap.out == "Hello World!" However, it is failing unexpectedly, saying that it captured the printing to stdout in the main output, but appears to have failed to make this captured stdout available in the test. Output on a GitHub Actions machine can be found here, as well as the source code that I am testing. Adding the explicit call to sys.stdout.flush() does not change anything locally. Pytest full local output
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
while not familiar with the cppstream library, its highly unlikely its using sys.stdout, but rather a lower level, please use fd capture and ensure the c++ streams flush sanely |
Beta Was this translation helpful? Give feedback.
while not familiar with the cppstream library, its highly unlikely its using sys.stdout, but rather a lower level, please use fd capture and ensure the c++ streams flush sanely