Last active
December 18, 2015 07:09
-
-
Save cgoldberg/5744573 to your computer and use it in GitHub Desktop.
Example using concurrencytest module: https://github.com/cgoldberg/concurrencytest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Example using `concurrencytest`: | |
# https://github.com/cgoldberg/concurrencytest | |
import time | |
import unittest | |
from concurrencytest import ConcurrentTestSuite, fork_for_tests | |
class SampleTestCase(unittest.TestCase): | |
def test_it(self): | |
time.sleep(0.5) | |
if __name__ == '__main__': | |
# load a TestSuite with 50x TestCases for demo | |
loader = unittest.TestLoader() | |
suite = unittest.TestSuite() | |
for _ in range(50): | |
suite.addTests(loader.loadTestsFromTestCase(SampleTestCase)) | |
print('Loaded %d test cases...' % suite.countTestCases()) | |
runner = unittest.TextTestRunner() | |
print('\nRun tests sequentially:') | |
runner.run(suite) | |
print('\nRun same tests across 50 processes:') | |
concurrent_suite = ConcurrentTestSuite(suite, fork_for_tests(50)) | |
runner.run(concurrent_suite) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment