Skip to main content

Tool for black-box testing command-line programs, with extensions

Project description

test_cmd_x

pypi

This is a tool for black-box testing command-line programs simply based on STDIN, STDOUT, and STDERR. test_cmd_x is a extended version of original test_cmd.

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_x.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

optional arguments:
  -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.

Project details


Download files

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

Source Distribution

test_cmd_x-2.0.3.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

test_cmd_x-2.0.3-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file test_cmd_x-2.0.3.tar.gz.

File metadata

  • Download URL: test_cmd_x-2.0.3.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.3

File hashes

Hashes for test_cmd_x-2.0.3.tar.gz
Algorithm Hash digest
SHA256 90ece4ba95d8b54630f04801e56217c9b504260f6df6e465badb1c9abffe4332
MD5 fb7b9495ace51581ddc8a6fa046ba367
BLAKE2b-256 1476e06310b1626c6e921a59c4a3131c5a38b229e3f82b1bc858b746372762c0

See more details on using hashes here.

File details

Details for the file test_cmd_x-2.0.3-py3-none-any.whl.

File metadata

  • Download URL: test_cmd_x-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.3

File hashes

Hashes for test_cmd_x-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a90d47d937c45c861bf64da373c2675de1706cc02e39cf52d1b8b9c6751c349c
MD5 99364f212729bdb34c26d909a4bd9276
BLAKE2b-256 d41a13686dacc0e99b0f514da73b6cb21d1d16272e540615b6a47030f623a939

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page