Skip to content

Commit

Permalink
Added test for issue click-contrib#17
Browse files Browse the repository at this point in the history
  • Loading branch information
edobezabb committed May 8, 2021
1 parent b671ae5 commit f95c2ad
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ def bar():
click.echo('bar')


@click.group(cls=DefaultGroup, default='baz', default_if_no_args=True, invoke_without_command=True)
@click.option('--verbose', is_flag=True)
def cli2(group_only):
if group_only:
click.echo('--verbose passed.')


@cli2.command()
@click.option('--baz', default='baz')
def baz(baz):
click.echo('baz called.')
click.echo(baz)


r = CliRunner()


Expand All @@ -37,6 +51,10 @@ def test_group_arguments():
assert r.invoke(cli, ['--group-only']).output == '--group-only passed.\n'


def test_group_arguments_call_default():
assert r.invoke(cli2, ['--verbose']).output == '--verbose passed.\nbaz called.\n'


def test_explicit_command():
assert r.invoke(cli, ['foo']).output == 'foo\n'
assert r.invoke(cli, ['bar']).output == 'bar\n'
Expand Down

0 comments on commit f95c2ad

Please sign in to comment.