Skip to content

Commit

Permalink
refactor: Don't import get_user_model() indirectly
Browse files Browse the repository at this point in the history
  • Loading branch information
pennersr committed Oct 20, 2023
1 parent 26158b2 commit 4f24552
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 9 deletions.
3 changes: 1 addition & 2 deletions allauth/account/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from django.conf import settings
from django.contrib import messages
from django.contrib.auth import update_session_auth_hash
from django.contrib.auth import get_user_model, update_session_auth_hash
from django.core.exceptions import FieldDoesNotExist
from django.db import models
from django.db.models import Q
Expand All @@ -18,7 +18,6 @@
from allauth.core.exceptions import ImmediateHttpResponse
from allauth.utils import (
get_request_param,
get_user_model,
import_callable,
valid_email_or_none,
)
Expand Down
3 changes: 2 additions & 1 deletion allauth/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
from contextlib import contextmanager
from unittest.mock import patch

from django.contrib.auth import get_user_model

import pytest

from allauth.account.models import EmailAddress
from allauth.account.utils import user_email, user_username
from allauth.core import context
from allauth.utils import get_user_model


@pytest.fixture
Expand Down
3 changes: 2 additions & 1 deletion allauth/socialaccount/providers/discord/tests.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from django.contrib.auth import get_user_model

from allauth.account.models import EmailAddress
from allauth.account.utils import user_email, user_username
from allauth.socialaccount import app_settings
from allauth.socialaccount.models import SocialAccount
from allauth.socialaccount.providers.discord.provider import DiscordProvider
from allauth.socialaccount.tests import OAuth2TestsMixin
from allauth.tests import MockedResponse, TestCase
from allauth.utils import get_user_model


class DiscordTests(OAuth2TestsMixin, TestCase):
Expand Down
2 changes: 1 addition & 1 deletion allauth/socialaccount/providers/facebook/tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json

from django.contrib.auth import get_user_model
from django.test.client import RequestFactory
from django.test.utils import override_settings
from django.urls import reverse
Expand All @@ -9,7 +10,6 @@
from allauth.socialaccount.models import SocialAccount
from allauth.socialaccount.tests import OAuth2TestsMixin
from allauth.tests import MockedResponse, TestCase, patch
from allauth.utils import get_user_model

from .provider import FacebookProvider

Expand Down
2 changes: 1 addition & 1 deletion allauth/socialaccount/providers/openid/tests.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from unittest import expectedFailure

from django.contrib.auth import get_user_model
from django.test import override_settings
from django.urls import reverse

from openid.consumer import consumer

from allauth.socialaccount.models import SocialAccount
from allauth.tests import Mock, TestCase, patch
from allauth.utils import get_user_model

from . import views
from .utils import AXAttribute
Expand Down
2 changes: 1 addition & 1 deletion allauth/socialaccount/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from urllib.parse import parse_qs, urlparse

from django.conf import settings
from django.contrib.auth import get_user_model
from django.test import RequestFactory
from django.test.utils import override_settings
from django.urls import reverse
Expand All @@ -25,7 +26,6 @@
mocked_response,
patch,
)
from allauth.utils import get_user_model


def setup_app(provider_id):
Expand Down
2 changes: 1 addition & 1 deletion allauth/socialaccount/tests/test_signup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import django
from django.contrib.auth import get_user_model
from django.contrib.auth.models import AnonymousUser
from django.contrib.messages.middleware import MessageMiddleware
from django.contrib.sessions.middleware import SessionMiddleware
Expand All @@ -16,7 +17,6 @@
from allauth.socialaccount.models import SocialAccount, SocialApp, SocialLogin
from allauth.socialaccount.views import signup
from allauth.tests import TestCase
from allauth.utils import get_user_model


class SignupTests(TestCase):
Expand Down
2 changes: 1 addition & 1 deletion allauth/socialaccount/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from django.contrib.auth import get_user_model
from django.test.utils import override_settings

from allauth.socialaccount.models import SocialAccount
from allauth.tests import TestCase
from allauth.utils import get_user_model


class UtilTests(TestCase):
Expand Down

0 comments on commit 4f24552

Please sign in to comment.