sor*_*rin 13 python performance multithreading unit-testing multicore
我正在使用python unittest来测试其他一些外部应用程序,但是需要花费太多时间来逐个运行测试.
我想知道如何通过使用多核的功能来加速这个过程.我可以调整unittest来并行执行测试吗?怎么样?
这个问题不能python GIL限制,因为事实上不是python代码需要时间,而是我执行的外部应用程序,目前通过os.system().
所述testtools包是支持同时运行的测试单元测试的延伸.它可以与继承的旧测试类一起使用unittest.TestCase.
例如:
import unittest
import testtools
class MyTester(unittest.TestCase):
# Tests...
suite = unittest.TestLoader().loadTestsFromTestCase(MyTester)
concurrent_suite = testtools.ConcurrentStreamTestSuite(lambda: ((case, None) for case in suite))
concurrent_suite.run(testtools.StreamResult())
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7817 次 |
| 最近记录: |