u-boot-brain/tools/concurrencytest
Simon Glass fe2400895b concurrencytest: Fix Python3 warning
This gives a warning in some situations:

  File "tools/dtoc/../concurrencytest/concurrencytest.py", line 95,
       in do_fork
    stream = os.fdopen(c2pread, 'rb', 1)
  File "/usr/lib/python3.8/os.py", line 1023, in fdopen
    return io.open(fd, *args, **kwargs)
RuntimeWarning: line buffering (buffering=1) isn't supported in binary
    mode, the default buffer size will be used

Fix this by dropping the line-buffer parameter.

Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-05 12:26:35 -07:00
..
.gitignore binman: Run tests concurrently 2018-10-08 07:34:34 -06:00
README.md tools: correct Markdown in concurrencytest/README.md 2020-01-30 13:30:35 -05:00
concurrencytest.py concurrencytest: Fix Python3 warning 2021-01-05 12:26:35 -07:00

README.md

concurrencytest

testing goats

Python testtools extension for running unittest suites concurrently.


Install from PyPI:

pip install concurrencytest

Requires:


Example:

import time
import unittest

from concurrencytest import ConcurrentTestSuite, fork_for_tests


class SampleTestCase(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)


# Load tests from SampleTestCase defined above
suite = unittest.TestLoader().loadTestsFromTestCase(SampleTestCase)
runner = unittest.TextTestRunner()

# Run tests sequentially
runner.run(suite)

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

Output:

....
----------------------------------------------------------------------
Ran 4 tests in 2.003s

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

OK