-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added echo
bool to capture.
#2338
Comments
I think #2172 is unrelated to what actually gets written to the terminal and is instead about |
Hello, i have been working on this. If echo is true by default it breaks the test below. Since new capture method prints all captured strings 'out' changes.
In order to pass previous tests should i just change default 'echo' value to 'false' ? Or does this test needs to be replaced ? |
IMHO, inside the test we should be explicit about echo argument, regardless what is the default value, especially as this is expected to change the final outcome. |
Okay, below is what you recommend then ?
While trying solve the problem, i have seen that even tho my code works for single recorder.print() call, it actually breaks when there is multiple of them. Since there is no test for that. It passes. So i have made test below in order to future-proof it. Can somebody give some feedback about it.
|
THe only hint I know about capturing standard streams is that your do not want to join them, especially for testing. If you ever do this, the order can be anything as each of them does have its own buffering. Even if there are some controls for buffering they often do not work as intended, being known that on several cases you cannot really disable the buffering. |
I see, calling readouterr twice in same test is unreliable. Below is new version:
Another thing which ı would like to ask is about recorder.export_text() function. It is defined as follows :
Above function creates unwanted behavior while working with multiple captures. Example :
Is this expected behavior ? I thought my code was the cause of it but even in master without echo argument it creates "'Hello\nHello\nWorld\n'" output. The first written test for capture called "test_capture_and_record" and it is using it. So i thought maybe i should also use it but in its current form i dont think it works correctly. Should i try to fix it or just skip it ? I do think main problem is below code, it seems to be doing some extra loops inside for.
|
The
capture
method should have anecho
parameter. Whenecho=True
(the default) text should be captured and written to the terminal. Whenecho=False
the text should be captured but not written to the terminal.See #2172 for context.
The text was updated successfully, but these errors were encountered: