MCPcopy
hub / github.com/pallets/click / test_catch_exceptions_cli_runner

Function test_catch_exceptions_cli_runner

tests/test_testing.py:190–209  ·  view source on GitHub ↗

Test that invoke `catch_exceptions` takes the value from CliRunner if not set explicitly.

()

Source from the content-addressed store, hash-verified

188
189
190def test_catch_exceptions_cli_runner():
191 """Test that invoke `catch_exceptions` takes the value from CliRunner if not set
192 explicitly."""
193
194 class CustomError(Exception):
195 pass
196
197 @click.command()
198 def cli():
199 raise CustomError(1)
200
201 runner = CliRunner(catch_exceptions=False)
202
203 result = runner.invoke(cli, catch_exceptions=True)
204 assert isinstance(result.exception, CustomError)
205 assert type(result.exc_info) is tuple
206 assert len(result.exc_info) == 3
207
208 with pytest.raises(CustomError):
209 runner.invoke(cli)
210
211
212def test_with_color():

Callers

nothing calls this directly

Calls 2

invokeMethod · 0.95
CliRunnerClass · 0.90

Tested by

no test coverage detected