-
Notifications
You must be signed in to change notification settings - Fork 101
Open
Description
I am trying to write a pytest test of one of my views that requires a logged-in admin user and I'm using the pytest-django admin_client
fixture for that.
This fails as follows:
try:
user = UserModel._default_manager.get(**{username_field: username})
except UserModel.DoesNotExist:
extra_fields = {}
if username_field not in ("username", "email"):
extra_fields[username_field] = "admin"
user = UserModel._default_manager.create_superuser(
> username, "[email protected]", "password", **extra_fields
)
E TypeError: create_superuser() takes 1 positional argument but 4 were given
../.virtualenvs/test3/lib/python3.7/site-packages/pytest_django/fixtures.py:298: TypeError
I investigated and it's because authtools defines create_superuser
like this:
def create_superuser(self, **kwargs):
using only one positional argument (self
). The pytest-django fixture tries to invoke the function like Django expects up until 3.0, using username, email and password. In 3.0 only username is required so this problem might be solved but I'm on 2.2 and you seem to support 1.11 and maybe earlier too.
So is this a bug? I can work around it for now but thought I'd notify you. And thanks for a great package btw
Metadata
Metadata
Assignees
Labels
No labels