Closed StopMotionCuber closed 4 years ago
The object returned by runner.invoke
has various attributes to inspect the result, including exception
.
Please use Stack Overflow for questions about your own code. This tracker is for issues related to the project itself. Be sure to include a minimal, complete, and verifiable example.
Hello everyone,
I'm having an issue with testing my click application that has a custom exception handler with click. I would like to use the CliRunner to test custom exception handling with click. Therefore I'm using a setup similar to the one found below.
Execute this script below with the parameter
action
(e.g.python3 script_name.py action
) to reproduce this error.Also I'd like to ask if this is the correct way to handle global exceptions. For me it does not make sense to handle the error in each subcommand, when there is e.g. a connection error to the server, which will always be handled the same way.
Expected Behavior
The Exception will be handled by the global handler in both cases, leading to a stdout of
Minimal example:
Actual Behavior
Tell us what happens instead.
The Exception is handled when manually executing, but not when ran with
CliRunner
.Environment