Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

pytest: Running parallel tests

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


    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
Advertisement