Testing CLI scripts


This is about testing scripts within the Launchpad context, not a general guide about testing CLI scripts.

run_script should only be used for smoke tests as these kinds of end-to-end tests slow down the test suite.

Launchpad offers a convenient test helper for testing scripts, which are usually found in the top level scripts folder.

from lp.testing.script import run_script

returncode, stdout, stderr = run_script(

For more available options please have a look at the source code of run_script.


run_script uses a subprocess to run the script. This has impact on both debugging via a Python debugger and on using strace (use strace -f).