summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAngus L'Herrou <piraka@brandeis.edu>2021-05-14 10:19:23 -0400
committerDavid Lord <davidism@gmail.com>2022-02-19 10:14:39 -0800
commit74e7f7079cb31578fa2578f219d93a33cfeb46f8 (patch)
tree7a22e7d0c9c06392cc955a32f077e4b04bd29dcf /tests
parent77961478cdaf9cf55c8b15fd1db0681ff75ffcfb (diff)
downloadclick-74e7f7079cb31578fa2578f219d93a33cfeb46f8.tar.gz
command and group decorator parentheses are optional
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"