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

Function test_catch_exceptions

tests/test_testing.py:166–187  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

164
165
166def test_catch_exceptions():
167 class CustomError(Exception):
168 pass
169
170 @click.command()
171 def cli():
172 raise CustomError(1)
173
174 runner = CliRunner()
175
176 result = runner.invoke(cli)
177 assert isinstance(result.exception, CustomError)
178 assert type(result.exc_info) is tuple
179 assert len(result.exc_info) == 3
180
181 with pytest.raises(CustomError):
182 runner.invoke(cli, catch_exceptions=False)
183
184 CustomError = SystemExit
185
186 result = runner.invoke(cli)
187 assert result.exit_code == 1
188
189
190def test_catch_exceptions_cli_runner():

Callers

nothing calls this directly

Calls 2

invokeMethod · 0.95
CliRunnerClass · 0.90

Tested by

no test coverage detected