I just ran into an issue where my test wasn't catching a bug I had because of this.
I gracefully catch errors:
result = ctx.run("my command", hide=False, echo=True)
if result.exited:
... do stuff
Now I forgot to add warn=True here, but wrote my tests with MockContext:
ctx = MockContext(
run={
"my command": Result("Mock output", exited=1),
}
)
... and checked the "do stuff" after the command returned a non-zero exit code worked as expected
My tests were passing without issue because MockContext isn't honoring the default warn=False. I found in production the error was not being caught because I forgot to set warn=True.
What should have happened was:
MockContext sees warn=False and pyinvoke immediately exits after the command returns a non-zero exit code
I just ran into an issue where my test wasn't catching a bug I had because of this.
I gracefully catch errors:
Now I forgot to add
warn=True
here, but wrote my tests with MockContext:My tests were passing without issue because MockContext isn't honoring the default
warn=False
. I found in production the error was not being caught because I forgot to setwarn=True
.What should have happened was:
warn=False
and pyinvoke immediately exits after the command returns a non-zero exit code