Skip to content
Myr

add tests for the runner when the app uses context.exit

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

authored by Joe Jevnik · committed by Stephen Rosen · parent 4308336 · Browse files · 2 files+32 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

2 files+32 added−0 removed

  • tests:+32 added−0 removed

2 files+32 added−0 removed

modified:tests/test_context.py+2 added
204 unmodified lines
205 assert not result.exception206 assert result.output == 'aha!\n'207 assert called == [True]208209210def test_make_pass_decorator_args(runner):211 """212 Test to check that make_pass_decorator doesn't consume arguments based on213 invocation order.
27 unmodified lines
241 result = runner.invoke(cli, ['test2'])242 assert not result.exception243 assert result.output == 'foocmd\n'244245246def test_exit_not_standalone_failure():247 @click.command()248 @click.pass_context249 def cli(ctx):
18 unmodified lines
modified:tests/test_testing.py+30 added
152 unmodified lines
153 click.echo('hello world')154 sys.exit('error')155156 @click.command()157 @click.pass_context158 def cli_string_ctx_exit(ctx):159 click.echo('hello world')160 ctx.exit('error')161162 @click.command()163 def cli_int():164 click.echo('hello world')165 sys.exit(1)166167 @click.command()168 @click.pass_context169 def cli_int_ctx_exit(ctx):170 click.echo('hello world')171 ctx.exit(1)172173 @click.command()174 def cli_float():175 click.echo('hello world')176 sys.exit(1.0)177178 @click.command()179 @click.pass_context180 def cli_float_ctx_exit(ctx):181 click.echo('hello world')182 ctx.exit(1.0)183184 @click.command()185 def cli_no_error():186 click.echo('hello world')187188 runner = CliRunner()
1 unmodified line
190 result = runner.invoke(cli_string)191 assert result.exit_code == 1192 assert result.output == 'hello world\nerror\n'193194 result = runner.invoke(cli_string_ctx_exit)195 assert result.exit_code == 1196 assert result.output == 'hello world\nerror\n'197198 result = runner.invoke(cli_int)199 assert result.exit_code == 1200 assert result.output == 'hello world\n'201202 result = runner.invoke(cli_int_ctx_exit)203 assert result.exit_code == 1204 assert result.output == 'hello world\n'205206 result = runner.invoke(cli_float)207 assert result.exit_code == 1208 assert result.output == 'hello world\n1.0\n'209210 result = runner.invoke(cli_float_ctx_exit)211 assert result.exit_code == 1212 assert result.output == 'hello world\n1.0\n'213214 result = runner.invoke(cli_no_error)215 assert result.exit_code == 0216 assert result.output == 'hello world\n'217
72 unmodified lines