mercredi 25 mars 2020

Run pytest script simultaneously with different occurrence

I want to execute pytest script simultaneously with different occurrence

Exemple for two Pytest script that I wish to run :

Script 1 : test_print1.py

def test_print(config_file):
    assert config_file

    res = 0
    assert res is 0

Script 2 : test_print2.py

def test_print(config_file):
    assert config_file

    res = 0
    assert res is 1

So here the two scenarios that I want to have (for example) :

  • Execute the two scripts simultaneously, but I want test_print1.py to be run two time and test_print3.py three times
  • Execute the two scripts simultaneously, but I want test_print1.py to be run on time and test_print3.py four times

I want to the execution happen in a single command line.

I've seen pytest-repeat but it repeats all the test n times which don't help here.

And I have also seen @pytest.mark.repeat(n) which must have it hard coded into my code and this doesn't help because every time I must go into the code and change it.

So is there any way to run multiple test simultaneously with different occurrence?

1 commentaire:

  1. That's exactly my problem, have you found any proper solution?

    RépondreSupprimer