craigahobbs / unittest-parallel

Parallel unit test runner for Python with coverage support
MIT License
29 stars 5 forks source link

Function level parallelization #8

Closed SweetVishnya closed 3 years ago

SweetVishnya commented 3 years ago

Is it possible to detect all test functions, split them in chuncks and run each chunk in a separate process? For Linux fork can be used.

SweetVishnya commented 3 years ago

Hmmm, after this fix all unittest functions run in parallel even when they are in same class.

SweetVishnya commented 3 years ago

Seems that unittest-parallel 1.2.0 solves my task))) So, I can just:

python -m pip install unittest-parallel==1.2.0
craigahobbs commented 3 years ago

Correct, that will install unittest-parallel globally (alongside python3). If you don't want to install globally, you can install in a venv:

python3 -m venv env
env/bin/pip install unittest-parallel
. env/bin/activate
unittest-parallel -v -t src -s src/tests
deactivate

Alternatively, you can skip activate/deactivate:

env/bin/unitest-parallel -v -t src -s src/tests
SweetVishnya commented 3 years ago

Hmmm, after this fix all unittest functions run in parallel even when they are in same class.

My main point was that now your tool runs all functions in one TestCase in parallel.

craigahobbs commented 3 years ago

That is surprising, and you are correct. That's just what Python's unittest.TestLoader.discover method is returning - one TestCase per test method. I've tested this with setUp and tearDown methods, and it all works, so this is a good thing. :)

craigahobbs commented 3 years ago

This change introduced an issue with setUpClass/tearDownClass:

https://github.com/craigahobbs/unittest-parallel/issues/9