Session Ready
Exercise

Invoking command line tests

Not only has your department widely adopted click, but you are writing click applications so quickly that you need to ensure you know how to test them as well. The click framework has the ability to test itself using the CliRunner method. Lead by example and extend this click application so it can be tested properly and integrated into your continuous integration system.

Remember that click flags like --something need to be passed into functions as something to use them in the function.

Instructions
100 XP
  • Define the click command using the two decorators: @click.command() and @click.option().
  • Use the CliRunner from click to run a command line click application.
  • Pass in --num 2 via the runner.invoke() command.
  • Assert that the result returns exit status of 0.