kvas-it / pytest-console-scripts

Pytest plugin for testing console scripts
MIT License
78 stars 14 forks source link

Print out return code, stdout and stderr output from the script on error #4

Closed kvas-it closed 5 years ago

a96tudor commented 6 years ago

Hey! I'd like to work on this. I just have a question: what do you mean by "error"? returncode != 0?

kvas-it commented 6 years ago

Hey! Cool.

By "error" I mean "when the test fails". The idea is that in most cases, when the test fails it's useful to see what the script under test did and what it printed out. I find myself inserting print(result.stdout) and print(result.stderr) into the test quite often to get this information. It would be nice if pytest-console-scripts did it automatically (and would save me some typing and another test run).

We can actually print those things out all the time -- normally this output would be swallowed by capturing machinery of pytest but if the test fails we would see it.

grant-humphries commented 5 years ago

+1 for this feature, this is what I use as a work around the mean time:

assert result.success, result.stderr