summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_command_decorators.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/test_command_decorators.py b/tests/test_command_decorators.py
new file mode 100644
index 0000000..8d07531
--- /dev/null
+++ b/tests/test_command_decorators.py
@@ -0,0 +1,37 @@
+import click
+
+
+def test_command_no_parens(runner):
+ @click.command
+ def cli():
+ click.echo("hello")
+
+ result = runner.invoke(cli)
+ assert result.exception is None
+ assert result.output == "hello\n"
+
+
+def test_group_no_parens(runner):
+ @click.group
+ def grp():
+ click.echo("grp1")
+
+ @grp.command
+ def cmd1():
+ click.echo("cmd1")
+
+ @grp.group
+ def grp2():
+ click.echo("grp2")
+
+ @grp2.command
+ def cmd2():
+ click.echo("cmd2")
+
+ result = runner.invoke(grp, ["cmd1"])
+ assert result.exception is None
+ assert result.output == "grp1\ncmd1\n"
+
+ result = runner.invoke(grp, ["grp2", "cmd2"])
+ assert result.exception is None
+ assert result.output == "grp1\ngrp2\ncmd2\n"