concurrencytest

0.1.11 · active · verified Thu Apr 16

The `concurrencytest` library, currently at version 0.1.11, enables parallel execution of standard Python `unittest` test suites across multiple worker processes. It aims to speed up test execution by leveraging CPU cores. The library is actively maintained, with its latest release in March 2026, and provides mechanisms to control the number of worker processes and how tests are distributed among them.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to set up a `unittest.TestCase` and run its tests concurrently using `concurrencytest`. It shows how to load a test suite and wrap it with `ConcurrentTestSuite`, specifying the number of worker processes.

import time
import unittest
from concurrencytest import ConcurrentTestSuite, fork_for_tests

class ExampleTestCase(unittest.TestCase):
    def test_slow_1(self):
        time.sleep(0.1)
        self.assertTrue(True)

    def test_slow_2(self):
        time.sleep(0.1)
        self.assertEqual(1 + 1, 2)

    def test_fast_3(self):
        self.assertFalse(False)

if __name__ == '__main__':
    # Load tests from current file
    suite = unittest.defaultTestLoader.loadTestsFromTestCase(ExampleTestCase)
    
    # Run tests concurrently using 2 processes
    # The default is fork_for_tests() which uses os.cpu_count() processes
    concurrent_suite = ConcurrentTestSuite(suite, fork_for_tests(2))
    
    runner = unittest.TextTestRunner(verbosity=2)
    runner.run(concurrent_suite)

view raw JSON →