pytest-dev / pytest-dev/pytest-django

Create helper fixtures for authenticated states on RequestFactory and client

Open
#565 0 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

I think the below are widely enough used on Django projects tests to be part of pytest-django itself.

  • Fixture to create a django user (similar to admin_user, but non-admin)
  • Create a user_client (similar to admin_user, but non-admin, related #553 #554)
  • Create a request factory for unauth users (for AttributeError: 'WSGIRequest' object has no attribute 'user' errors). Helps mimic user middleware fast of falling back on AnonymousUser. See also, this example in Django docs
  • Request factory for normal django user
  • Request factory for admin user https://github.com/pytest-dev/pytest-django/issues/284

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 locating the existing admin_user, user_client, and request-factory fixtures referenced in the issue, then compare their behavior with the requested authenticated and anonymous states. Done means the listed user, client, and request-factory fixtures are available and covered by the project's tests.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.