Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

execute several times a test with pytest

Tags:

python

pytest

Is there a way to run a test x times with py.test?

What I'm looking for it's to repeat a test several times, because the tests has random fixtures.

Something like py.test -n100

I've been playing with pytest-xdist but if I understand well it only distributes the tests among the cpus.

like image 656
Félix Avatar asked Jan 25 '26 20:01

Félix


1 Answers

Actually you may try running with pytest-xdist like this:

py.test --dist=each --tx=3*popen

This will run the same tests 3 times in three different subprocesses.

like image 63
hpk42 Avatar answered Jan 27 '26 18:01

hpk42



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!