Skip to main content

Build Status

doctest-cli

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

Installation

With pip:

pip install doctest-cli

By hand:

curl -O https://github.com/ivan-krukov/doctest-cli/blob/master/bin/doctest-cli ~/bin
chmod +x ~/bin/doctest-cli

Usage

Create a test script, say test.sh:

# Command
>>> echo hello
# Expected output
hello

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

# Failing
>>> echo banana
apple

Test it:

doctest-cli test.sh

Check output:

doctest-cli: test/simple.sh
------------------------------------------------------------
Error while running:
  echo banana
With STDERR:

Expected STDOUT:
  apple
Got:
  banana
------------------------------------------------------------
Tests ran: 3
Tests passed: 2
Tests failed: 1

Dependencies

The program depends on python - both 2.7 and 3.4 and above should work

Extra

See test/ for more examples.

Return code

Check return code by adding $?=<RET> to the beginning of the line. Default return code is 0:

>>> false
$?=1
>>> true
$?=0

Standard error

Check stderr output by adding ! to the beginning of the line:

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

By default, the stderr stream is assumed to be empty.

Custom shell

You can use a custom shell with a shebang line:

#!/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 the output against the lines provided. All the environment variables are inherited from the parent session.

Whitespace (including intervening newlines) is ignored. For example, the following test should pass, since all the newlines in the middle are removed:

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

This is done so that you can have an arbitrary amount of whitespace delineating the test blocks.

Metadata

Release files for doctest-cli 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for doctest-cli 0.0.3
File Size Uploaded Provenance Actions
doctest-cli-0.0.3.tar.gz 3.5 kB Without provenance Details for doctest-cli-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for doctest-cli 0.0.3
File Interpreter ABI Platform Actions
doctest_cli-0.0.3-py3-none-any.whl Python 3 none any Details for doctest_cli-0.0.3-py3-none-any.whl

Total release size: 7.3 kB

Release files / doctest-cli-0.0.3.tar.gz

Download URL doctest-cli-0.0.3.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
44c8ae83e477bb6c056bde37df3aa30f84af91459554fb0ee4a7eb523f78b9b4
BLAKE2b-256 checksum
How to use checksums
17420a1eb83ad45efc680c0202edef5d0af0b5a96dbd9c199f2e2d447d50e420
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0

Release files / doctest_cli-0.0.3-py3-none-any.whl

Download URL doctest_cli-0.0.3-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bdd5e23107d3e8c35dbf6a9dcf1e6260ecb9ad0a40c316037a4f4326e2329f3f
BLAKE2b-256 checksum
How to use checksums
3d8438acb645d0dcb89aca51d267c0651da8aee6b643d3b4ba15aa545ff24845
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0

Security for doctest-cli 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page