Skip to content
Myr

Merge pull request #378 from aspyatkin/patch-1

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Add note about subcommands testing. Closes #377

authored by Markus Unterwaditzer · committed by Markus Unterwaditzer · parents 04e2021, f705ee4 · Browse files · 1 file+23 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+23 added−0 removed

  • other:+23 added−0 removed

1 file+23 added−0 removed

modified:docs/testing.rst+23 added
36 unmodified lines
37 result = runner.invoke(hello, ['Peter'])38 assert result.exit_code == 039 assert result.output == 'Hello Peter!\n'4041For subcommand testing, a subcommand name must be specified in the `args` parameter of :meth:`CliRunner.invoke` method.4243Example::4445 import click46 from click.testing import CliRunner47 48 def test_sync():49 @click.group()50 @click.option('--debug/--no-debug', default=False)51 def cli(debug):52 click.echo('Debug mode is %s' % ('on' if debug else 'off')) 53 54 @cli.command()55 def sync():56 click.echo('Syncing')57 58 runner = CliRunner()59 result = runner.invoke(cli, ['--debug', 'sync'])60 assert result.exit_code == 061 assert 'Debug mode is on' in result.output62 assert 'Syncing' in result.output6364File System Isolation65---------------------6667For basic command line tools that want to operate with the file system, the
46 unmodified lines