diff options
author | IamCathal <cathalsocallaghan@gmail.com> | 2020-07-06 16:47:51 +0100 |
---|---|---|
committer | David Lord <davidism@gmail.com> | 2020-08-05 08:06:53 -0700 |
commit | 32ddbb11f210dd679439241c6619cad8bcafca67 (patch) | |
tree | c002785fe61b1aae36509d44a11d25d5181aad40 /tests/test_chain.py | |
parent | 28154558840b43864acc688ed9248db1c4007a12 (diff) | |
download | click-32ddbb11f210dd679439241c6619cad8bcafca67.tar.gz |
non-chained group invoked without command invokes result callback
Diffstat (limited to 'tests/test_chain.py')
-rw-r--r-- | tests/test_chain.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/test_chain.py b/tests/test_chain.py index 0462779..74a04f1 100644 --- a/tests/test_chain.py +++ b/tests/test_chain.py @@ -88,6 +88,25 @@ def test_chaining_with_options(runner): assert result.output.splitlines() == ["bdist called 1", "sdist called 2"] +@pytest.mark.parametrize(("chain", "expect"), [(False, "None"), (True, "[]")]) +def test_no_command_result_callback(runner, chain, expect): + """When a group has ``invoke_without_command=True``, the result + callback is always invoked. A regular group invokes it with + ``None``, a chained group with ``[]``. + """ + + @click.group(invoke_without_command=True, chain=chain) + def cli(): + pass + + @cli.resultcallback() + def process_result(result): + click.echo(str(result), nl=False) + + result = runner.invoke(cli, []) + assert result.output == expect + + def test_chaining_with_arguments(runner): @click.group(chain=True) def cli(): |