Skip to main content

Doctests for your shell

Project description

Build Status

doctest-cli

Doctests for your shell. Run an executable, check the output.

Usage

Create a test script, say test.sh:

# Command
>>> echo hello
# Expected output
hello

# Another command
>>> echo 'Good bye!'
Good bye!

Test it:

./doctest-cli test.sh
doctest-cli: testing test/simple.sh
------------------------------------------------------------
All 2 tests passed

Dependencies

  • python

Extra

Check return code:

>>> false
$?=1

Check stderr output:

>>> echo error > /dev/stderr
! error

Custom shell:

#!/usr/local/bin/fish
>>> echo hello; and echo this is fish
hello
this is fish

Details

doctest-cli uses python's Subprocess module to spawn a new shell for each command and checks it against the provided output. All the environment variables are inherited from the current session.

Whitespace (including intervening newlines) is ignored. For example, the following test should pass:

>>>printf 'hello\n\n\n\n\n\nworld'
hello
world

Project details


Download files

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

Files for doctest-cli, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size doctest_cli-0.0.1-py3-none-any.whl (3.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size doctest-cli-0.0.1.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page