pytest-dev / pytest-dev/pytest-django

Running with xdist results in unexpected 403 status codes from DRF APIClient

Open
#961 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
367
PR merge metrics
No merged PRs in 30d

Description

Hey all, I have a large passing test suite that doesn't seem to get along with pytest-xdist.

The status code responses from the Django Rest Framework test APIClient suddenly all become 403 errors.

The client uses a fixture for the user that is being supplied for authentication. There is no higher scoping given to anything (e.g. no session, module, etc scoping).

Are there any known problems that I'm missing here?

Versions:

django==3.2.9
pytest==6.2.5
pytest-django==4.4.0
pytest-xdist==2.4.0

From pytest runs:

platform darwin -- Python 3.8.1, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
plugins: asyncio-0.16.0, django-4.3.0, xdist-2.4.0, forked-1.3.0

Contributor guide

Open the contributing guide

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 reproducing the 403 responses with the listed Django, pytest, pytest-django, and pytest-xdist versions, comparing normal and xdist runs. Inspect the DRF APIClient authentication fixture and pytest-xdist interaction; done means identifying a reproducible cause and documenting or fixing the behavior with a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
backend, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.