Skip to main content

Python testtools extension for running unittest test suites concurrently

Project description

concurrencytest

testing goats

Python testtools extension for running unittest test suites concurrently.


  • Development: GitHub
  • Download/Install: PyPI
  • License: GPLv2+
  • Copyright (c) 2013-2026 Corey Goldberg
  • Original code from:
    • Bazaar (bzrlib.tests.__init__.py, v2.6, copied Jun 01 2013)
    • Copyright (c) 2005-2011 Canonical Ltd

About

concurrencytest allows you to parallelize a unnittest tests across a configurable number of worker processes. Tests are assigned to worker processes in a round-robin fashion.

This module provides the ConcurrentTestSuite class from testtools and the fork_for_tests function (make_tests implementation needed to use ConcurrentTestSuite).

You can specify the number of worker process to use when calling fork_for_tests, or use the default concurrecy (1 process per available CPU core).


Install from PyPI:

pip install concurrencytest

Requires:

  • support for os.fork() (Unix-like systems only)
  • testtools : pip install testtools
  • python-subunit : pip install python-subunit

Example:

import time
import unittest

from concurrencytest import ConcurrentTestSuite, fork_for_tests


class ExampleTestCase(unittest.TestCase):
    """Dummy tests that sleep for demo."""

    def test_me_1(self):
        time.sleep(0.5)

    def test_me_2(self):
        time.sleep(0.5)

    def test_me_3(self):
        time.sleep(0.5)

    def test_me_4(self):
        time.sleep(0.5)


runner = unittest.TextTestRunner()

# Run the tests from above sequentially
suite = unittest.TestLoader().loadTestsFromTestCase(ExampleTestCase)
runner.run(suite)

# Run same tests concurrently across 4 processes
suite = unittest.TestLoader().loadTestsFromTestCase(ExampleTestCase)
concurrent_suite = ConcurrentTestSuite(suite, fork_for_tests(4))
runner.run(concurrent_suite)

# Run same tests concurrently using 1 process per available CPU core
suite = unittest.TestLoader().loadTestsFromTestCase(ExampleTestCase)
concurrent_suite = ConcurrentTestSuite(suite, fork_for_tests())
runner.run(concurrent_suite)

Output:

.....
----------------------------------------------------------------------
Ran 4 tests in 2.002s

OK
....
----------------------------------------------------------------------
Ran 4 tests in 0.510s

OK
....
----------------------------------------------------------------------
Ran 4 tests in 0.507s

OK

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

concurrencytest-0.1.8.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

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

concurrencytest-0.1.8-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file concurrencytest-0.1.8.tar.gz.

File metadata

  • Download URL: concurrencytest-0.1.8.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for concurrencytest-0.1.8.tar.gz
Algorithm Hash digest
SHA256 0cf2d8a47565df6059de2a162665958378f07ef0d228619ba166c1f0fc7a0d5c
MD5 def027ecaa5c732c5148e85d132366dc
BLAKE2b-256 6c71147e6669e79bbf002723059f63fdab3c9697c6f2aedd4773e9344d585f32

See more details on using hashes here.

File details

Details for the file concurrencytest-0.1.8-py3-none-any.whl.

File metadata

File hashes

Hashes for concurrencytest-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 7d37bc682bc4c1efe967a06a4de6fa53226b93f33452d5d8311a82a1a061b3c4
MD5 131ace2f1c1f1a1bce3c6a87bdca521c
BLAKE2b-256 caae07d1cefa81ef1ec781627541f5975d07a7f311a1b6563a6183738ca8d766

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