0

To run parallel tests on mobile devices, I use pytest + xdist.

I want to run as many threads as I have connected devices, no more.

I pass "-n 4" as command line argument, but I can't change it after test launch if I need 2 threads, not 4.

How can I adjust the number of threads from the my test code?

MrBean Bremen
  • 14,916
  • 3
  • 26
  • 46
lunin
  • 51
  • 6

2 Answers2

0

I think you're looking for this.

Samarth
  • 627
  • 6
  • 13
  • Unfortunately, this hook will not be called for conftest.py files, only for setuptools plugins. https://docs.pytest.org/en/latest/reference.html#_pytest.hookspec.pytest_load_initial_conftests So, I don't understand how use this hook in the conftest.py – lunin Nov 30 '18 at 15:24
  • Oh, so that means the documentation is not correct. Because on that page, they have specified `# content of conftest.py`. – Samarth Nov 30 '18 at 15:57
0

if you have a minimal way to know it in python, i propose creating a python script that will call pytest.main with the correct arguments