pytest-dev / pytest-dev/pytest-xdist

Support running a fixture only once per entire execution

Open
#783 13 comments 16 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.9k
Forks
287
Avg merge
9h 30m
Merged PRs (30d)
2

Description

For some cases, we might want the setup of the test to run only once, even when something is multi processed, for example:

We write our end-to-end tests in python using pytest, this means that one of our fixtures takes care of bringing up the entire environment of the test.

One of the current problems we are facing with parallelizing our tests is that we can't use xdist, since it runs a session-scoped fixture for every instance.

A way to run a fixture only once, no matter how many processes are there would be very beneficial for such cases where the setup should only run once in a background process.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing how pytest session-scoped fixtures behave when pytest-xdist runs tests in multiple processes. Compare the current xdist fixture lifecycle with the requested single background setup, including how processes would coordinate and share its result. Done means a fixture can be configured to initialize once across the entire execution while parallel workers continue using it safely.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
distributed-systems, testing-qa
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.