Skip to content

Commit 7c4c219

Browse files
authored
Full test coverage (#52)
* grammar typo * test_help_option parametrize
1 parent a468470 commit 7c4c219

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

click_option_group/_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def get_help_record(self, ctx: click.Context) -> Optional[Tuple[str, str]]:
173173
return name, help_
174174

175175
def option(self, *param_decls: str, **attrs: Any) -> Callable:
176-
"""Decorator attaches an grouped option to the command
176+
"""Decorator attaches a grouped option to the command
177177
178178
The decorator is used for adding options to the group and to the Click-command
179179
"""

tests/test_click_option_group.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -733,10 +733,15 @@ def cli(foo, bar):
733733
assert "bar" not in result.output
734734

735735

736-
def test_help_option(runner):
736+
@pytest.mark.parametrize('param_decls, options, output', [
737+
((), ['--help'], '--help'),
738+
(('-h', '--help'), ['-h'], '-h, --help'),
739+
(('-h', '--help'), ['--help'], '-h, --help'),
740+
])
741+
def test_help_option(runner, param_decls, options, output):
737742
@click.command()
738743
@optgroup('Help Options')
739-
@optgroup.help_option('-h', '--help')
744+
@optgroup.help_option(*param_decls)
740745
def cli() -> None:
741746
click.echo('Running command.')
742747

@@ -745,11 +750,11 @@ def cli() -> None:
745750
assert 'Running command.' in result.output
746751
assert 'Usage:' not in result.output
747752

748-
result = runner.invoke(cli, ['-h'])
753+
result = runner.invoke(cli, options)
749754
assert not result.exception
750755
assert 'Running command.' not in result.output
751756
assert 'Usage:' in result.output
752-
assert '-h, --help' in result.output
757+
assert output in result.output
753758

754759

755760
def test_wrapped_functions(runner):

0 commit comments

Comments
 (0)