Skip to content

painless-software/python-cli-test-helpers

Repository files navigation

cli-test-helpers Latest version on PyPI

Code checks status Test suite status Latest release Status Python versions Software license Documentation Status

Useful helpers for writing tests for your Python CLI program.

Writing tests for a command line interface (CLI) application is more difficult than it seems at first sight. Especially, when you use the argparse module or the docopt or click package, control of the application entry point is a bit taken away from you.

But it's not all that bad. This package is here to help. The Painless Software CLI Copier template offers some guidance on how to get started, and the CLI test helpers allow you to deal with common cases, such as mocking CLI arguments and environment variable values.

Documentation

See the documentation for installation instructions and a tutorial.

Examples / Quickstart

Visit the Painless Software CLI Copier template to inspect hands-on CLI application blueprints for the most popular CLI frameworks. The Copier tool lets you create your own CLI application project with tests and modern CI/CD, effortlessly.

Development

This project uses Tox to run its test suite. Install and use it locally like this:

python3 -m pip install tox
tox list            # list available environments
tox -e lint,py312   # run a few environments
tox -e py           # run tests with local default Python
tox                 # run entire suite