Skip to main content

Useful helpers for writing tests for your Python CLI program.

Project description

Code checks status Test suite 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

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.3.0.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for cli-test-helpers-3.3.0.tar.gz
Algorithm Hash digest
SHA256 0d1fcdf476de349e06b4b0374d0ba965c867431dc4cf8b2a64a50010b5ddd3e9
MD5 9c1391d2a2d2741f724e729e8d3f00cf
BLAKE2b-256 75763597354396f2eacdeb68fba1bdac4182e98e6447feccbe8c310f4ce9dd24

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cli_test_helpers-3.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b9479811c7db842fec6620e34fc0ebd587385d000a6f8c91c8fe18d65d8046ea
MD5 4bba0c8efe7b5d42e17e52c3676d6c9c
BLAKE2b-256 cbe31392b828a36d7113c490bf967ceaab59ba4ab3bf8e0b1a420a3bf0bc551f

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