Users

These fixtures are related to Django users.

pytest_djangoapp.fixtures.users.user(user_create)

Exposes Django user object.

Shortcut for user_create fixture.

Example:

def test_this(user):
    username = user.username

Note

User password is accessible via password_plain attribute.

pytest_djangoapp.fixtures.users.user_create(user_model)

Allows Django user object generation.

Example:

def test_this(user_create):
    user = user_create()

Note

User password is accessible via password_plain attribute.

Parameters
  • superuser (bool) – Whether to create a superuser.

  • anonymous (bool) – Whether to create an anonymous user.

  • attributes (dict) – Additional user object attributes to initialize.

pytest_djangoapp.fixtures.users.user_model()

Returns user model class.

Example:

def test_this(user_model):
    model_cls = user_model