-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add option to suppress printing RunResult on init #41
Comments
Hi Geoffrey! Thanks for this ticket. It made me realize that I messed up: my intention was to only print out the result if the test fails. By default this is more or less how it works, but when the output capturing is disabled with something like However, there's no easy way to print only on test failure, at least I don't see it, because at the time when What do you think? I'm happy to implement your original request and/or a command line option. Cheers, |
Vasily, Thanks for replying. I didn't even realize that I was suppressing the output capturing since I'm running the test suite through PyCharm which must automatically add that flag when running the pytest module. Sorry to make you have to go through and try to figure out what I was talking about since it doesn't show on normal invocation. I agree with you that there's not a great way to only print on test failure. Could there be an if statement in the init block that would be, I think that a global flag would be better to disable capturing. What would your proposal be for the command line option and how would it interact with the larger pytest suite? Thanks, Geoffrey |
No worries, I knew more or less what's happening right away when I read your ticket. And if the tests behave this way in PyCharm, that's also not great so it would be good to fix it.
Yes, this is possible. But the thing is: nonzero returncode is not necessarily a failure. Some tests check that the script under test correctly handles errors so signaling error would be right (and
When you run Regarding the command line option, it can be something like So I'm thinking that we have three possible paths to investigate:
Let me know if any of this sounds good. Cheers, P.S. Sorry for too much text 🤷 |
Hi Geoffrey! The In any case, it seems like the command line option and the additional argument to Cheers, |
Hey Vasily! Unfortunately, I played with both commenting the offending line of code and changing the I just realized also, that I never showed what the actual output of the test results were. So I'll paste an example below (with names changed for brevity),
But in either case, thanks for all your help with solving this! I'm looking forward to trying out both solutions. Best, Geoffrey |
Hi Geoffrey! Can you check out the version from this branch and let me know if it solves your problem? Cheers, |
Merged and released. Thanks for the feedback, Geoffrey! |
Hello, I would like the option to suppress the automatic printing of the RunResult class in the init (Lines 107-109 in pytest_console_scripts.py).
I think that a relatively easy way to do this is to have RunResult take a default parameter - print_output = True and use that as a flag to print the return code, stdout, and stderr.
This flag could be set in the ScriptRunner object and then passed through the run commands.
Thanks,
The text was updated successfully, but these errors were encountered: