Skip to main content

A parallel Python test runner built around subunit

Project description

Build status Appveyor build status Code coverage Latest Version

You can see the full rendered docs at: http://stestr.readthedocs.io/en/latest/

Overview

stestr is parallel Python test runner designed to execute unittest test suites using multiple processes to split up execution of a test suite. It also will store a history of all test runs to help in debugging failures and optimizing the scheduler to improve speed. To accomplish this goal it uses the subunit protocol to facilitate streaming and storing results from multiple workers.

stestr originally started as a fork of the testrepository that concentrates on being a dedicated test runner for python projects. The generic abstraction layers which enabled testrepository to work with any subunit emitting runner are gone. stestr hard codes python-subunit-isms into how it works. The code base is also designed to try and be explicit, and to provide a python api that is documented and has examples.

While stestr was originally forked from testrepository it is not 100% backwards compatible with testrepository. At a high level the basic concepts of operation are shared between the 2 projects but the actual usage between the 2 is not exactly the same.

Installing stestr

stestr is available via pypi, so all you need to do is run:

pip install -U stestr

to get stestr on your system. If you need to use a development version of stestr you can clone the repo and install it locally with:

git clone https://github.com/mtreinish/stestr.git && pip install -e stestr

which will install stestr in your python environment in editable mode for local development

Using stestr

After you install stestr to use it to run tests is pretty straightforward. The first thing you’ll need to do is create a .stestr.conf file for your project. This file is used to tell stestr where to find tests and basic information about how tests are run. A basic minimal example of the contents of this is:

[DEFAULT]
test_path=./project_source_dir/tests

which just tells stestr the relative path for the directory to use for test discovery. This is the same as --start-directory in the standard unittest discovery

After this file is created you should be all set to start using stestr to run tests. You can create a repository for test results with the stestr init command, just run:

stestr init

and it will create a .stestr directory in your cwd that will be used to store test run results. (if you run stestr run it will create this if it doesn’t exist) Then to run tests just use:

stestr run

it will then execute all the tests found by test discovery. If you’re just running a single test (or module) and want to avoid the overhead of doing test discovery you can use the --no-discover/-n option.

For all the details on these commands and more thorough explanation of options see the stestr manual: https://stestr.readthedocs.io/en/latest/MANUAL.html

Migrating from testrepository

If you have a project that is already using testrepository stestr’s source repo contains a helper script for migrating your repo to use stestr. This script just creates a .stestr.conf file from a .testr.conf file. (assuming it uses a standard subunit.run test command format) To run this from your project repo just call:

$STESTR_SOURCE_DIR/tools/testr_to_stestr.py

and you’ll have a .stestr.conf created.

Building a manpage

The stestr manual has been formatted so that it renders well as html and as a manpage. The html output and is autogenerated and published to: https://stestr.readthedocs.io/en/latest/MANUAL.html but the manpage has to be generated by hand. To do this you have to manually run sphinx-build with the manpage builder. This has been automated in a small script that should be run from the root of the stestr repository:

tools/build_manpage.sh

which will generate the troff file in doc/build/man/stestr.1 which is ready to be packaged and or put in your system’s man pages.

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

stestr-2.2.0.tar.gz (103.8 kB view details)

Uploaded Source

Built Distributions

stestr-2.2.0-py3-none-any.whl (109.2 kB view details)

Uploaded Python 3

stestr-2.2.0-py2-none-any.whl (108.1 kB view details)

Uploaded Python 2

File details

Details for the file stestr-2.2.0.tar.gz.

File metadata

  • Download URL: stestr-2.2.0.tar.gz
  • Upload date:
  • Size: 103.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for stestr-2.2.0.tar.gz
Algorithm Hash digest
SHA256 0c7f4894300d5d9f7eb21679ccd9a74608fe8e224c382f5e5b6dc4e7de2e87ff
MD5 0b120b66edd5bb0e1c8bb4db4ce38569
BLAKE2b-256 ca97278dbb40069e885325a5fc9095ab6080b7be8cdce89fbac2bccefe3e4231

See more details on using hashes here.

File details

Details for the file stestr-2.2.0-py3-none-any.whl.

File metadata

  • Download URL: stestr-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 109.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for stestr-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bd372984fe07890c96e6a980735effd4c2a6a331163470b2b10e71acbfd44f8a
MD5 b34f7863267fa4c7bfc7c77ba89f3beb
BLAKE2b-256 1963d30a1041a303c7dfce9f700f567e8dd45de53bbc06b7038b916028a6e4ce

See more details on using hashes here.

File details

Details for the file stestr-2.2.0-py2-none-any.whl.

File metadata

  • Download URL: stestr-2.2.0-py2-none-any.whl
  • Upload date:
  • Size: 108.1 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for stestr-2.2.0-py2-none-any.whl
Algorithm Hash digest
SHA256 2d6acaa7df65fee37deaa145c6a07edecf32f9d280601b40613a3463d288d812
MD5 0d9e45ea1626d4fe93a0532e837f305f
BLAKE2b-256 32d9c91653d8452d42a7dd53555709154bbc2dbd494f967f72bcfc057f20c694

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