You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
...which makes it difficult to see programming errors.
Perhaps it should only catch click specific exceptions.
Here's an example.
importunittestimportclickfromclick.testingimportCliRunner@click.command()@click.argument('bar')deffoo():
""" This command will raise a TypeError('foo() takes no arguments (1 given)',) when called via runner.invoke, but you won't see that when testing with CliRunner.invoke. """click.echo('hello world\n')
classVolumeTests(unittest.TestCase):
deftest_noarguments(self):
runner=CliRunner()
result=runner.invoke(foo, ['baz'])
self.assertEqual(b'hello world\n', result.output)
# Only way to see the error is by examining the exception attribute.# self.assertEqual(b'', result.exception)if__name__=='__main__':
unittest.main()
changed the title [-]click.testing.invoke swallows programming errors[/-][+]click.testing.CliRunner.invoke swallows programming errors[/+]on Jun 9, 2014
Activity
[-]click.testing.invoke swallows programming errors[/-][+]click.testing.CliRunner.invoke swallows programming errors[/+]mitsuhiko commentedon Jun 14, 2014
Click 3.0 has a flag to control this.
jongio commentedon Jan 29, 2018
runner.invoke(loader.loader, ["-t", "rdr", fname], catch_exceptions=False)
jsmedmar commentedon Jun 4, 2018
A note about this in the testing docs would be great
simonw commentedon Jun 23, 2020
Looks like this is covered by the documentation here: https://click.palletsprojects.com/en/7.x/api/#testing