использую py.test и pytest-xdist
перед каждым тестом -
@pytest.mark.parametrize(['driver','url'], [[chrome_driver, login_url],[chrome_driver1,login_url1]])
def test_login_and_dashboard(driver,url):
"""test"""
запускаю как py.test -n 2 -v test.py
проблема в том что инстансы запускаются два, но проходят они по очереди ( пока в первом не пройдет - второй не запускается ) и в итоге я получаю - очень много времени прохождения тестов .
посоветуйте как запускать их действительно параллельно ?
Тоже столкнулся с этим же
Неужели нет решений?
1 Like
polusok
(Mykhailo Poliarush)
September 23, 2016, 6:58am
#3
Увы официальных решений пока еще нет
opened 10:45PM - 10 Jan 16 UTC
I may just be misunderstanding how xdist works, but I can't seem to get the numb… er of workers I requested to all accept tasks in parallel:
```
$ py.test -v -n 8
================================ test session starts =================================
platform darwin -- Python 3.5.1, pytest-2.8.5, py-1.4.31, pluggy-0.3.1 -- .../pytest-xdist-testcase/venv/bin/python3
cachedir: .cache
rootdir: .../pytest-xdist-testcase, inifile:
plugins: xdist-1.13.1
[gw0] darwin Python 3.5.1 cwd: .../pytest-xdist-testcase
[gw1] darwin Python 3.5.1 cwd: .../pytest-xdist-testcase
[gw2] darwin Python 3.5.1 cwd: .../pytest-xdist-testcase
[gw3] darwin Python 3.5.1 cwd: .../pytest-xdist-testcase
[gw4] darwin Python 3.5.1 cwd: .../pytest-xdist-testcase
[gw5] darwin Python 3.5.1 cwd: .../pytest-xdist-testcase
[gw6] darwin Python 3.5.1 cwd: .../pytest-xdist-testcase
[gw7] darwin Python 3.5.1 cwd: .../pytest-xdist-testcase
[gw0] Python 3.5.1 (default, Dec 7 2015, 21:59:10) -- [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)]
[gw1] Python 3.5.1 (default, Dec 7 2015, 21:59:10) -- [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)]
[gw2] Python 3.5.1 (default, Dec 7 2015, 21:59:10) -- [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)]
[gw3] Python 3.5.1 (default, Dec 7 2015, 21:59:10) -- [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)]
[gw4] Python 3.5.1 (default, Dec 7 2015, 21:59:10) -- [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)]
[gw5] Python 3.5.1 (default, Dec 7 2015, 21:59:10) -- [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)]
[gw6] Python 3.5.1 (default, Dec 7 2015, 21:59:10) -- [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)]
[gw7] Python 3.5.1 (default, Dec 7 2015, 21:59:10) -- [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)]
gw0 [8] / gw1 [8] / gw2 [8] / gw3 [8] / gw4 [8] / gw5 [8] / gw6 [8] / gw7 [8]
scheduling tests via LoadScheduling
test_tests.py::test_1[0]
test_tests.py::test_1[2]
test_tests.py::test_2[0]
test_tests.py::test_2[2]
[gw0] PASSED test_tests.py::test_1[2]
[gw7] PASSED test_tests.py::test_1[0]
[gw2] PASSED test_tests.py::test_2[0]
[gw4] PASSED test_tests.py::test_2[2]
test_tests.py::test_2[1]
test_tests.py::test_1[3]
test_tests.py::test_1[1]
test_tests.py::test_2[3]
[gw7] PASSED test_tests.py::test_1[1]
[gw0] PASSED test_tests.py::test_1[3]
[gw4] PASSED test_tests.py::test_2[3]
[gw2] PASSED test_tests.py::test_2[1]
============================= 8 passed in 64.12 seconds ==============================
```
Watching the output as it comes, it looks like the second block of 4 tests doesn't start running until the first block of 4 completes.
Am I misunderstanding something? Why don't all 8 workers start running tests at the same time? Why doesn't `gw1`, for example, get any tests?