pytest-dev / pytest-dev/pytest-xdist

Session-Scoped Fixtures are not Session-Scoped with Pytest-Xdist

Open
#271 65 comments 55 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I am fairly new to this project. I very recently migrated a software project test-suite from nosetest to pytest, mainly because of the Xdist benefits I had heard of.

The problem is that my Tests are depending on a big fixture setup (table creation + heavy loading of data) that I would like to share across all my tests.

The current Xdist behaviour is as follow:

  1. Collect test
  2. Split tests amongst the user-defined number of processes
  3. Launch a pytest session for each worker

Obviously, if each test depend on a heavy fixture, then multiplying the number of creation per number of worker is not going to help.

Additionally, it simply breaks the expected pytest behaviour for 'session' scoped fixtures.

I think this should be fairly simple to address this problem although I didn't take a really deep look into it. If you need help to solve this problem, I am more than willing to contribute if you feel this suggestion for improvement is relevant.

Greetings.

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

The issue names no source files, tests, or entry points. Start by reading pytest-xdist's worker/session setup and existing fixture-related tests, then determine how session-scoped fixtures should behave across workers. Done means the intended sharing behavior is defined and covered by tests without breaking distributed execution.

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
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.