I am trying to check the return value of the result_callback
of my cli. In the code below I can check the stdout, but I want the actual value returned.
Does anyone know how to get the output value of the result_callback when testing?
import click
from click.testing import CliRunner
@click.group()
def main():
pass
@main.command()
@click.argument("name")
def hello(name):
return name
@main.result_callback()
def process_result(result):
result = "".join(reversed(result))
click.echo(f"Hello {result}!")
return result
def test_hello_world():
runner = CliRunner()
observed = runner.invoke(main, ["hello", "Peter"])
assert observed.exit_code == 0
assert observed.output == "Hello reteP!n"
# assert observed.callback_value == "reteP" # how to do this???