1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

[5.0.x] Applied Black's 2024 stable style.

https://github.com/psf/black/releases/tag/24.1.0

Backport of 305757aec1 from main
This commit is contained in:
Mariusz Felisiak
2024-01-26 12:45:07 +01:00
parent 86dd89e623
commit 0379e7532f
234 changed files with 804 additions and 599 deletions

View File

@@ -3,6 +3,7 @@ The CustomPermissionsUser users email as the identifier, but uses the normal
Django permissions model. This allows us to check that the PermissionsMixin
includes everything that is needed to interact with the ModelBackend.
"""
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin
from django.db import models

View File

@@ -486,8 +486,9 @@ class AuthenticationFormTest(TestDataMixin, TestCase):
user_login_failed.disconnect(signal_handler)
def test_inactive_user_i18n(self):
with self.settings(USE_I18N=True), translation.override(
"pt-br", deactivate=True
with (
self.settings(USE_I18N=True),
translation.override("pt-br", deactivate=True),
):
# The user is inactive.
data = {
@@ -906,9 +907,9 @@ class UserChangeFormTest(TestDataMixin, TestCase):
class MyUserForm(UserChangeForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields[
"groups"
].help_text = "These groups give users different permissions"
self.fields["groups"].help_text = (
"These groups give users different permissions"
)
class Meta(UserChangeForm.Meta):
fields = ("groups",)

View File

@@ -327,8 +327,9 @@ class TestUtilsHashPass(SimpleTestCase):
with mock.patch.object(hasher, "rounds", 4):
encoded = make_password("letmein", hasher="bcrypt")
with mock.patch.object(hasher, "rounds", 6), mock.patch.object(
hasher, "encode", side_effect=hasher.encode
with (
mock.patch.object(hasher, "rounds", 6),
mock.patch.object(hasher, "encode", side_effect=hasher.encode),
):
hasher.harden_runtime("wrong_password", encoded)
@@ -502,8 +503,9 @@ class TestUtilsHashPass(SimpleTestCase):
with mock.patch.object(hasher, "iterations", 1):
encoded = make_password("letmein")
with mock.patch.object(hasher, "iterations", 6), mock.patch.object(
hasher, "encode", side_effect=hasher.encode
with (
mock.patch.object(hasher, "iterations", 6),
mock.patch.object(hasher, "encode", side_effect=hasher.encode),
):
hasher.harden_runtime("wrong_password", encoded)
@@ -551,8 +553,9 @@ class TestUtilsHashPass(SimpleTestCase):
hasher = get_hasher("default")
encoded = make_password("letmein")
with mock.patch.object(hasher, "harden_runtime"), mock.patch.object(
hasher, "must_update", return_value=True
with (
mock.patch.object(hasher, "harden_runtime"),
mock.patch.object(hasher, "must_update", return_value=True),
):
# Correct password supplied, no hardening needed
check_password("letmein", encoded)

View File

@@ -818,9 +818,9 @@ class LoginTest(AuthViewsTestCase):
# Use POST request to log in
SessionMiddleware(get_response).process_request(req)
CsrfViewMiddleware(get_response).process_view(req, LoginView.as_view(), (), {})
req.META[
"SERVER_NAME"
] = "testserver" # Required to have redirect work in login view
req.META["SERVER_NAME"] = (
"testserver" # Required to have redirect work in login view
)
req.META["SERVER_PORT"] = 80
resp = CsrfViewMiddleware(LoginView.as_view())(req)
csrf_cookie = resp.cookies.get(settings.CSRF_COOKIE_NAME, None)