Skip to main content

Utility for testing command line scripts

Project description

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.

travis-ci kindly tests the code automatically under Python versions 2.7, and 3.3 through 3.6.

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.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distribution

scripttester-0.1.tar.gz (24.7 kB view details)

Uploaded Source

File details

Details for the file scripttester-0.1.tar.gz.

File metadata

  • Download URL: scripttester-0.1.tar.gz
  • Upload date:
  • Size: 24.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for scripttester-0.1.tar.gz
Algorithm Hash digest
SHA256 2fbd06425b48fadd6b4ef07d9e00d3c0fffada56a0f15d8d75619e78ee6451e4
MD5 89de2cc315ba6d0e1395ce1225590aad
BLAKE2b-256 4b8c938e078b90f4d085aad7c31192efd4f7aadc2e1da6de54c6f7428c340553

See more details on using hashes here.

Supported by

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