Imagine that I have test/unit/...
which are safe to run in parallel and test/functional/...
which cannot be run in parallel yet.
Is there an easy way to convince pytest to run the functional
ones sequentially? Consider that we are talking about a big number of tests so altering each test function/method would be very noisy.
At this moment we run tests with marker filters so mainly we run them separated. Still, I am looking for a solution for removing the need to run them separated.
You can implement your own scheduler that acts like load
or loadscope
, depending on what module the test is defined in. Example:
from xdist.scheduler.loadscope import LoadScopeSchedulingclass MyScheduler(LoadScopeScheduling):def _split_scope(self, nodeid):if 'test/functional' in nodeid:return 'functional-tests'return nodeiddef pytest_xdist_make_scheduler(config, log):return MyScheduler(config, log)
All tests under test/functional
will be grouped under the same node functional-tests
(and thus run in the same worker), the rest will be run in parallel as usual.