You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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, "admin@example.com", "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 ☺️ .
The text was updated successfully, but these errors were encountered:
Thanks for the issue and sorry for letting this sit for so long. We're unsure how to update this without breaking backwards compatibility, but we are open to ideas and PRs.
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:
I investigated and it's because authtools defines
create_superuser
like this: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☺️ .
The text was updated successfully, but these errors were encountered: