Skip to main content

ScriptTester - utility for testing command line scripts

Quickstart

Provides class to be instantiated in tests that check that scripts can be run and give correct output. Usually works something like this in a test module:

import mymodule
from scripttester import ScriptTester
runner = ScriptTester(mymodule)

Then, in the tests, something like:

code, stdout, stderr = runner.run_command(['my-script', my_arg])
assert code == 0
assert stdout == b'This script ran OK'

The class aims to find your scripts whether you have installed (with pip install . or pip install -e . or python setup.py install), or not. If you have not installed, the scripts will not be on your system PATH, and we have to find them. The heuristic is to look (by default) in the directory containing mymodule; if there is a setup.py file there, and a scripts sub-directory, assume that directory contains the scripts.

Note there is no way of using this not-installed mechanism to find entrypoint scripts, that have not been installed. To find these, we would have to run the setup.py file.

Installation

pip install scripttester

Code

See https://github.com/matthew-brett/scripttester

Released under the BSD two-clause license - see the file LICENSE in the source distribution.

GitHub Actions tests the code automatically under Python versions 3.11 through 3.15, on Linux, macOS and Windows.

The latest released version is at https://pypi.python.org/pypi/scripttester

Tests

  • Install scripttester

  • Install the pytest testing framework:

    pip install pytest
  • Run the tests with:

    py.test --pyargs scripttester

Support

Please put up issues on the scripttester issue tracker.

Metadata

Release files for scripttester 0.2.0

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

Source distribution (sdist)

Source distribution for scripttester 0.2.0
File Size Uploaded Provenance Actions
scripttester-0.2.0.tar.gz 9.5 kB Without provenance Details for scripttester-0.2.0.tar.gz

Release files / scripttester-0.2.0.tar.gz

Download URL scripttester-0.2.0.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
242c0302d7120086aec2f140f94b0a13689ea2ac08beb9c1eced3614a5cafe28
BLAKE2b-256 checksum
How to use checksums
899c02ed80044224af19b0e9091def9c18b6400e3ef0c0c4143646501e5fe4d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.12

Security for scripttester 0.2.0

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

1 release file No provenance

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