pytest-dev / pytest-django

A Django plugin for pytest.
https://pytest-django.readthedocs.io/
Other
1.39k stars 344 forks source link

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

Open timworx opened 2 years ago

timworx commented 2 years ago

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
tim-win commented 2 years ago

I also have this issue

sshishov commented 2 years ago

I am not a maintainer, but it is very difficult to say what is wrong just reading your comments. It would be great to have the small reproducible example on which we can see the issue and reproduce it and then debug and fix.