shtest tests shell commands in your Sphinx documentation. The shtest directive supports the usual doctest syntax. It offers the following options:
:returncode: [integer]specifies the expected return code (defaults to 0).adding the
:stderr:flag compares results with thestderrrather thanstdoutstream.:cwd: [relative path]specifies the working directory relative to the source of the document (defaults to the directory containing the source document).:tempdir:executes the test in a temporary directory.
Examples
# Obligatory hello world example.
$ echo hello world
hello world
:stderr:
# Read from stderr instead of stdout.
$ echo message on stderr >&2
message on stderr
:returncode: 1
# Use a non-zero expected return code.
$ false
# Run multiple tests in one directive.
$ echo hello
hello
$ echo world
world
:cwd: tests
# Run a test in a particular working directory relative to the document.
$ cat hello.txt
world
:tempdir:
# Run a test in a temporary directory.
$ echo hello > world.txt
Installation
Run pip install sphinxcontrib-shtest to install the package and add "sphinxcontrib.shtest" to your extensions list in conf.py (see here for details). Then execute sphinx-build -b shtest /path/to/source/directory /path/to/output/directory.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file sphinxcontrib-shtest-0.5.0.tar.gz.
File metadata
- Download URL: sphinxcontrib-shtest-0.5.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/4.0.1 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65753c0ae0869ccfac53218cb491a253cd3965e730b74496c65c8938975cfafc
|
|
| MD5 |
fed2d1359e123274fafede3d79b2fe16
|
|
| BLAKE2b-256 |
c0f06a4deed6434d9fc80ed33069b51895cfb9ac1eb2d3f578493beb3645360f
|