How can I adjust the number of threads with pytest + xdist?

1.9k views Asked by At

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?

2

There are 2 answers

2
Samarth On

I think you're looking for this.

0
AudioBubble On

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