Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to speedup python unittest on muticore machines? [duplicate]

I'm using python unittest in order to test some other external application but it takes too much time to run the test one by one.

I would like to know how can I speedup this process by using the power of multi-cores. Can I tweak unittest to execute tests in parallel? How?

This question is not able python GIL limitation because in fact not the python code takes time but the external application that I execute, currently via os.system().

like image 577
sorin Avatar asked Jan 15 '10 19:01

sorin


People also ask

How can I make my unit test faster?

Identifying and pushing tests to a lower level makes tests faster and reliable. Join hands with developers, review the unit-tests and add more to the unit-levels. By reviews, you can avoid test duplication in multiple layers. Add integration test, if applicable.

Do Python Unittests run in parallel?

By default, unittest-parallel runs unit tests on all CPU cores available.

Is Pytest faster than unittest?

The code in pytest is simple, compact, and efficient. For unittest, we will have to import modules, create a class and define the testing functions within that class. But for pytest, we only have to define the testing function. Pytest is also fast and efficient.

Does unit test run in parallel?

To ensure that this growing test suite does not waste developer time, it is necessary to learn how to run these tests in parallel. Python unittest does not offer a solution to this problem.


1 Answers

If your tests are not too involved, you may be able to run them using py.test which has support for distributed testing. If you are not running on Windows, then nose might also work for you.

like image 96
Vinay Sajip Avatar answered Oct 19 '22 04:10

Vinay Sajip