Skip to main content

Useful helpers for writing tests for your Python CLI program.

Project description

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) tool may not seem strictly straight-forward when you think in terms of unit tests. Especially, when you use the argparse module or the 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 examples give you some guidance on how to get started, and the 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

The examples folder contains hands-on example projects you can start to use directly.

Development

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

python3 -m pip install tox 'virtualenv<20.22'
tox list            # list available environments
tox -e ruff,py311   # run a few environments
tox -e py           # run tests with local default Python
tox                 # run entire suite

The included example projects can be tested independently with their dedicated environments, e.g.

tox -e example-docopt

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cli-test-helpers-3.5.0.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

cli_test_helpers-3.5.0-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file cli-test-helpers-3.5.0.tar.gz.

File metadata

  • Download URL: cli-test-helpers-3.5.0.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for cli-test-helpers-3.5.0.tar.gz
Algorithm Hash digest
SHA256 86d5dea5b4fee4767cd87ff26eb709ad06764545e0fa348bace735247054b23e
MD5 78d9c8d8dc6c3140115237c90b73f6e1
BLAKE2b-256 61ba52016808e8924edffc631be52ad76a5c7497272ae98b93d19389d61596dc

See more details on using hashes here.

File details

Details for the file cli_test_helpers-3.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cli_test_helpers-3.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e05359625f9134d20df284bc32dd7e1002925945fe7ff0912351e6b08f55cee8
MD5 bf8575debf89ceca4da688ddac27f030
BLAKE2b-256 0c24c8432bcbed58fc71301eca6b64a3f53cce976479eb3a1f0f31e0b3c25deb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page