'How to run some testcases in parallel and some serially in pytest?

I have a few hundreds of tests and I want some of them to run in parallel, and some to run serially, within the same run.

I am aware how to run them all parallelly, or all serially, but not combined.

Is there any way to do this in pytest?



Solution 1:[1]

There are a few different ways to achieve this using the pytest-xdist plugin specifying --dist with loadscope, loadfile, or loadgroup.

Refer to the docs for details: https://pypi.org/project/pytest-xdist/#running-tests-across-multiple-cpus

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Teejay Bruno