Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

pytest: Running parallel tests

  • 26-10-2021 02:11PM
    #1
    Registered Users, Registered Users 2 Posts: 5,762 ✭✭✭


    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, Registered Users 2 Posts: 1,470 ✭✭✭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