Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

pytest: Running parallel tests

Options
  • 26-10-2021 2:11pm
    #1
    Registered Users Posts: 5,553 ✭✭✭


    So i have my code with 10 tests, all run sequentially


    So test 2 has the @pytest dependson 'test1' annotation

    test3 has @pytest dependson 'test2' annotation


    and so on.


    So ive learned that test1 and test2 dont care how each other runs. I want them to run in parallel but not start test3 until both pass. How do i achieve this



Comments

  • Registered Users Posts: 1,463 ✭✭✭Anesthetize


    Do you mind me asking why there's a dependency between those tests in the first place, and can this be avoided? One of the golden rules of unit tests is that they should not be dependent on each other. Is there another way of setting up the pre-conditions needed for test3 without having to run test1 and test2?

    Breaking that dependency might make life easier for you. You can then use a plugin like https://github.com/pytest-dev/pytest-xdist which divides the tests between multiple CPUs (if you're confident that tests won't collide with each other.)



Advertisement