pytest-dev / pytest-dev/pytest-django
Request factory with a preset admin user
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 367
- PR merge metrics
- No merged PRs in 30d
Description
Wouldn't it be reasonable to have a request factory, which sets user field by default on every created request? Like admin_client does. For example:
@fixture
def rf_admin(admin_user):
from django.test.client import RequestFactory
class AdminRequestFactory(RequestFactory):
def request(self, **request):
r = super().request(**request)
r.user = admin_user
return r
return AdminRequestFactory()
Because 90% of the time I use rf fixture I set admin_user on it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the existing rf fixture and the admin_client fixture, then inspect how Django's RequestFactory is used in the plugin's tests. Define the fixture's expected name and behavior, including when it assigns admin_user, and add coverage showing that created requests receive that user.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- backend, testing
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100