loadscope on parametrized classes not going parallel
See original GitHub issueI am parametrizing a test class and scheduling tests with --dist loadscope
. I was expecting the effect that every parameter combination will be treated as a separate class by pytest. Then, those parametrized runs should be able to go to different pytest processes when using loadscope. However, I am not seeing that behavior. All runs stay on the same process always. There doesn’t seem to be any different in scheduling behavior when using loadscope between parametrizing a test method versus parametrizing a test class.
What is the expected behavior with loadscope and parametrized classes? And if they are supposed to run in parallel, is this a bug?
(lux-D-BxQKsC-py3.8) ➜ test cat testp.py
import pytest
@pytest.mark.parametrize("paramvalue", ["p1", "p2"])
class TestClass:
def test_method_1(self, paramvalue):
assert True
def test_method_2(self, paramvalue):
assert True
(lux-D-BxQKsC-py3.8) ➜ test pytest -n auto --dist loadscope -vvv testp.py
==================================================== test session starts ====================================================
platform darwin -- Python 3.8.12, pytest-6.2.4, py-1.11.0, pluggy-0.13.1 -- /Users/manub/Library/Caches/pypoetry/virtualenvs/lux-D-BxQKsC-py3.8/bin/python
cachedir: .pytest_cache
rootdir: /Users/manub/tmp/test
plugins: xdist-2.5.0, forked-1.4.0, rerunfailures-10.2, mock-3.7.0, dotenv-0.5.2, profiling-1.7.0
[gw0] darwin Python 3.8.12 cwd: /Users/manub/tmp/test
[gw1] darwin Python 3.8.12 cwd: /Users/manub/tmp/test
[gw2] darwin Python 3.8.12 cwd: /Users/manub/tmp/test
[gw3] darwin Python 3.8.12 cwd: /Users/manub/tmp/test
[gw4] darwin Python 3.8.12 cwd: /Users/manub/tmp/test
[gw5] darwin Python 3.8.12 cwd: /Users/manub/tmp/test
[gw0] Python 3.8.12 (default, Nov 29 2021, 23:59:10) -- [Clang 11.0.3 (clang-1103.0.32.62)]
[gw1] Python 3.8.12 (default, Nov 29 2021, 23:59:10) -- [Clang 11.0.3 (clang-1103.0.32.62)]
[gw2] Python 3.8.12 (default, Nov 29 2021, 23:59:10) -- [Clang 11.0.3 (clang-1103.0.32.62)]
[gw3] Python 3.8.12 (default, Nov 29 2021, 23:59:10) -- [Clang 11.0.3 (clang-1103.0.32.62)]
[gw4] Python 3.8.12 (default, Nov 29 2021, 23:59:10) -- [Clang 11.0.3 (clang-1103.0.32.62)]
[gw5] Python 3.8.12 (default, Nov 29 2021, 23:59:10) -- [Clang 11.0.3 (clang-1103.0.32.62)]
gw0 [4] / gw1 [4] / gw2 [4] / gw3 [4] / gw4 [4] / gw5 [4]
scheduling tests via LoadScopeScheduling
testp.py::TestClass::test_method_1[p1]
[gw0] [ 25%] PASSED testp.py::TestClass::test_method_1[p1]
testp.py::TestClass::test_method_1[p2]
[gw0] [ 50%] PASSED testp.py::TestClass::test_method_1[p2]
testp.py::TestClass::test_method_2[p1]
[gw0] [ 75%] PASSED testp.py::TestClass::test_method_2[p1]
testp.py::TestClass::test_method_2[p2]
[gw0] [100%] PASSED testp.py::TestClass::test_method_2[p2]
===================================================== 4 passed in 0.86s =====================================================
(lux-D-BxQKsC-py3.8) ➜ test
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:5
Top Results From Across the Web
pytest-xdist indirect fixtures with class scope - Stack Overflow
When I use loadscope, all the tests are executed against gw0 and I am not getting any parallelism. I am wondering if there...
Read more >pytest-xdist - PyPI
The pytest-xdist plugin extends pytest with new test execution modes, the most used being distributing tests across multiple CPUs to speed up test...
Read more >Part 2: PyTest - Run your test with Markers and In Parallel Mode
In this video, I have explained how to run your test cases in groups using markers and run test cases in parallel mode.To...
Read more >TADDM 7.3 Fix Pack 5 - Readme - IBM
Go to the %COLLATION_HOME%/dist/bin directory. b. Enter the ./control stop command. c. If not all of the Java processes have stopped after entering...
Read more >View pypi: pytest-xdist - Debricked
--dist loadscope : Tests are grouped by module for test functions and by ... If not distributing tests (for example passing `-n0` or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If I have understood,
loadscope
relies on the string generated bypytest
to determine how to group the tests.https://github.com/pytest-dev/pytest-xdist/blob/61132777f8d85f7e03837684fbbdb41cb4f9c486/src/xdist/scheduler/loadscope.py#L270-L292
So to get this to work, I think we would need a change in
pytest
itself so thatbecomes
I was thinking something like
and I would expect both the “foo” and “bar” test to go to the same worker.
But I also agree that with your example I would expect
test_case1
andtest_case2
to go to the same worker.