test_cmd 
This is a tool for black-box testing command-line programs simply based on STDIN, STDOUT, and STDERR, with multiple CPUs. A sempahore keeps track of which CPUs are in use; and thus, tests are run in parallel on all CPUs, and new test runs are dispatched as tests complete (or fail). test_cmd waits until all tests have completed (either successfully or failed), and prints failed tests’ STDERR output, as they fail, in real time.
Tutorial
Test cases usually consist of pairs of input and output files, as well as an optional tests.json file specifying applicable command-line arguments. The input file is piped in via STDIN. If the command being tested emits the expected output file via STDOUT, the test case passes. A file representing an expected STDERR output can also optionally be specified.
The input/output file pairs must follow this naming pattern:
test-A.in.txt -> test-A.out.txt test-B.in.txt -> test-B.out.txt, test-B.err.txt test-C.in.txt -> test-C.out.txt
The file extension (.txt here) can be anything. The file naming pattern is *.in* for input files, *.out* for expected output files, and *.err* for expected error files. The content of the *.in.* file is piped to the command being tested, and its STDOUT is compared against the *.out* file. If a *.err.* file has been provided, then the command STDERR is matched against it as well.
For an example of test_cmd in action, see the pypage project, particularly its tests folder.
Usage
usage: test_cmd.py [-h] [-b] [-d] [-u] [-t] tests_dir cmd ... Functional Testing Utility for Command-Line Applications positional arguments: tests_dir Path to the directory containing test cases cmd Path to the command to be tested args The command-line arguments with an ampersand character '@' markingwhere arguments from test.json should be injected options: -h, --help show this help message and exit -b, --bw black & white output -d, --diff diff output -u, --to-unix convert CR+LF to LF in cmd output and test files -t, --rtrim ignore trailing whitespaces at the end of each line as well as trailing newlines
Command-line arguments for test cases can be specified by creating a special file named tests.json, and placing it in the directory containing your test cases. This tests.json file maps test cases to objects representing command-line arguments for that test case. If a command-line argument is a non-string value (e.g. a complex JavaScript object), the argument is stringified (with Python’s json.dumps), and passed in as JSON.
Metadata
Release files for test-cmd 2.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| test_cmd-2.0.6.tar.gz | 9.5 kB | Without provenance | Details for test_cmd-2.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| test_cmd-2.0.6-py3-none-any.whl | Python 3 | none | any | Details for test_cmd-2.0.6-py3-none-any.whl |
Total release size: 19.7 kB
Release files / test_cmd-2.0.6.tar.gz
| Download URL | test_cmd-2.0.6.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04861d7a9e9defd8d2021abe6d96960b459cd105360f711bfb1362e2a8a5226c
|
|
BLAKE2b-256 checksum How to use checksums |
aa7acefe5c04af32bd8b2f64fa5353b8ade65076b3262a9c82cd8d4a51c7697d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Release files / test_cmd-2.0.6-py3-none-any.whl
| Download URL | test_cmd-2.0.6-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0c0615e53de9b18b5d926966cbf386194d70cf6ef86216166537b1ebfa10e2c0
|
|
BLAKE2b-256 checksum How to use checksums |
274cc643cfdd744a742d47a7e9b17f917a44a31c751adfa7a03ba974133617a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Security for test-cmd 2.0.6
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.