diff options
author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-02-04 08:08:27 +0100 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-02-07 20:37:05 +0100 |
commit | 7119f40c9881666b6f9b5cf7df09ee1d21cc8344 (patch) | |
tree | fa50869f5614295f462d9bf77fec59365c621609 /tests/auth_tests | |
parent | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 (diff) | |
download | django-7119f40c9881666b6f9b5cf7df09ee1d21cc8344.tar.gz |
Refs #33476 -- Refactored code to strictly match 88 characters line length.
Diffstat (limited to 'tests/auth_tests')
-rw-r--r-- | tests/auth_tests/test_checks.py | 10 | ||||
-rw-r--r-- | tests/auth_tests/test_forms.py | 49 | ||||
-rw-r--r-- | tests/auth_tests/test_hashers.py | 3 | ||||
-rw-r--r-- | tests/auth_tests/test_management.py | 26 | ||||
-rw-r--r-- | tests/auth_tests/test_views.py | 5 | ||||
-rw-r--r-- | tests/auth_tests/urls.py | 4 |
6 files changed, 74 insertions, 23 deletions
diff --git a/tests/auth_tests/test_checks.py b/tests/auth_tests/test_checks.py index cd19fbcc9b..5757946f95 100644 --- a/tests/auth_tests/test_checks.py +++ b/tests/auth_tests/test_checks.py @@ -89,7 +89,10 @@ class UserModelChecksTests(SimpleTestCase): checks.Warning( "'CustomUserNonUniqueUsername.username' is named as " "the 'USERNAME_FIELD', but it is not unique.", - hint="Ensure that your authentication backend(s) can handle non-unique usernames.", + hint=( + "Ensure that your authentication backend(s) can handle " + "non-unique usernames." + ), obj=CustomUserNonUniqueUsername, id="auth.W004", ), @@ -264,8 +267,9 @@ class ModelsPermissionsChecksTests(SimpleTestCase): errors, [ checks.Error( - "The verbose_name of model 'auth_tests.Checked' must be at most 244 " - "characters for its builtin permission names to be at most 255 characters.", + "The verbose_name of model 'auth_tests.Checked' must be at most " + "244 characters for its builtin permission names to be at most 255 " + "characters.", obj=Checked, id="auth.E007", ), diff --git a/tests/auth_tests/test_forms.py b/tests/auth_tests/test_forms.py index 1713d367c3..ea52254123 100644 --- a/tests/auth_tests/test_forms.py +++ b/tests/auth_tests/test_forms.py @@ -174,10 +174,15 @@ class UserCreationFormTest(TestDataMixin, TestCase): @override_settings( AUTH_PASSWORD_VALIDATORS=[ { - "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator" + "NAME": ( + "django.contrib.auth.password_validation." + "UserAttributeSimilarityValidator" + ) }, { - "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", + "NAME": ( + "django.contrib.auth.password_validation.MinimumLengthValidator" + ), "OPTIONS": { "min_length": 12, }, @@ -259,7 +264,10 @@ class UserCreationFormTest(TestDataMixin, TestCase): @override_settings( AUTH_PASSWORD_VALIDATORS=[ { - "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator" + "NAME": ( + "django.contrib.auth.password_validation." + "UserAttributeSimilarityValidator" + ) }, ] ) @@ -267,13 +275,18 @@ class UserCreationFormTest(TestDataMixin, TestCase): form = UserCreationForm() self.assertEqual( form.fields["password1"].help_text, - "<ul><li>Your password can’t be too similar to your other personal information.</li></ul>", + "<ul><li>" + "Your password can’t be too similar to your other personal information." + "</li></ul>", ) @override_settings( AUTH_PASSWORD_VALIDATORS=[ { - "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator" + "NAME": ( + "django.contrib.auth.password_validation." + "UserAttributeSimilarityValidator" + ) }, ] ) @@ -610,10 +623,15 @@ class SetPasswordFormTest(TestDataMixin, TestCase): @override_settings( AUTH_PASSWORD_VALIDATORS=[ { - "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator" + "NAME": ( + "django.contrib.auth.password_validation." + "UserAttributeSimilarityValidator" + ) }, { - "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", + "NAME": ( + "django.contrib.auth.password_validation.MinimumLengthValidator" + ), "OPTIONS": { "min_length": 12, }, @@ -651,10 +669,15 @@ class SetPasswordFormTest(TestDataMixin, TestCase): @override_settings( AUTH_PASSWORD_VALIDATORS=[ { - "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator" + "NAME": ( + "django.contrib.auth.password_validation." + "UserAttributeSimilarityValidator" + ) }, { - "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", + "NAME": ( + "django.contrib.auth.password_validation.MinimumLengthValidator" + ), "OPTIONS": { "min_length": 12, }, @@ -663,7 +686,8 @@ class SetPasswordFormTest(TestDataMixin, TestCase): ) def test_help_text_translation(self): french_help_texts = [ - "Votre mot de passe ne peut pas trop ressembler à vos autres informations personnelles.", + "Votre mot de passe ne peut pas trop ressembler à vos autres informations " + "personnelles.", "Votre mot de passe doit contenir au minimum 12 caractères.", ] form = SetPasswordForm(self.u1) @@ -1129,7 +1153,10 @@ class ReadOnlyPasswordHashTest(SimpleTestCase): ) def test_render(self): widget = ReadOnlyPasswordHashWidget() - value = "pbkdf2_sha256$100000$a6Pucb1qSFcD$WmCkn9Hqidj48NVe5x0FEM6A9YiOqQcl/83m2Z5udm0=" + value = ( + "pbkdf2_sha256$100000$a6Pucb1qSFcD$WmCkn9Hqidj48NVe5x0FEM6A9YiOqQcl/83m2Z5u" + "dm0=" + ) self.assertHTMLEqual( widget.render("name", value, {"id": "id_password"}), """ diff --git a/tests/auth_tests/test_hashers.py b/tests/auth_tests/test_hashers.py index 7650548d2b..b767c2823d 100644 --- a/tests/auth_tests/test_hashers.py +++ b/tests/auth_tests/test_hashers.py @@ -390,7 +390,8 @@ class TestUtilsHashPass(SimpleTestCase): encoded = hasher.encode("lètmein", "seasalt2") self.assertEqual( encoded, - "pbkdf2_sha256$390000$seasalt2$geC/uZ92nRXDSjSxeoiBqYyRcrLzMm8xK3ro1QS1uo8=", + "pbkdf2_sha256$390000$seasalt2$geC/uZ92nRXDSjSxeoiBqYyRcrLzMm8xK3r" + "o1QS1uo8=", ) self.assertTrue(hasher.verify("lètmein", encoded)) diff --git a/tests/auth_tests/test_management.py b/tests/auth_tests/test_management.py index 41596a2210..071ea85a65 100644 --- a/tests/auth_tests/test_management.py +++ b/tests/auth_tests/test_management.py @@ -202,7 +202,8 @@ class ChangepasswordManagementCommandTestCase(TestCase): self.assertEqual( command_output, - "Changing password for user 'joe'\nPassword changed successfully for user 'joe'", + "Changing password for user 'joe'\n" + "Password changed successfully for user 'joe'", ) self.assertTrue(User.objects.get(username="joe").check_password("not qwerty")) @@ -267,7 +268,8 @@ class MultiDBChangepasswordManagementCommandTestCase(TestCase): self.assertEqual( command_output, - "Changing password for user 'joe'\nPassword changed successfully for user 'joe'", + "Changing password for user 'joe'\n" + "Password changed successfully for user 'joe'", ) self.assertTrue( User.objects.using("other").get(username="joe").check_password("not qwerty") @@ -785,7 +787,10 @@ class CreatesuperuserManagementCommandTestCase(TestCase): @override_settings( AUTH_PASSWORD_VALIDATORS=[ { - "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator" + "NAME": ( + "django.contrib.auth.password_validation." + "UserAttributeSimilarityValidator" + ) }, ] ) @@ -830,7 +835,10 @@ class CreatesuperuserManagementCommandTestCase(TestCase): AUTH_USER_MODEL="auth_tests.CustomUser", AUTH_PASSWORD_VALIDATORS=[ { - "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator" + "NAME": ( + "django.contrib.auth.password_validation." + "UserAttributeSimilarityValidator" + ) }, ], ) @@ -877,7 +885,10 @@ class CreatesuperuserManagementCommandTestCase(TestCase): AUTH_USER_MODEL="auth_tests.CustomUser", AUTH_PASSWORD_VALIDATORS=[ { - "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator" + "NAME": ( + "django.contrib.auth.password_validation." + "UserAttributeSimilarityValidator" + ) }, ], ) @@ -1094,7 +1105,10 @@ class CreatesuperuserManagementCommandTestCase(TestCase): stdout=new_io, stderr=new_io, ) - msg = "Error: That username is already taken.\nSuperuser created successfully." + msg = ( + "Error: That username is already taken.\n" + "Superuser created successfully." + ) self.assertEqual(new_io.getvalue().strip(), msg) test(self) diff --git a/tests/auth_tests/test_views.py b/tests/auth_tests/test_views.py index 5ba05e8a00..38e2234416 100644 --- a/tests/auth_tests/test_views.py +++ b/tests/auth_tests/test_views.py @@ -172,7 +172,10 @@ class PasswordResetTest(AuthViewsTestCase): self.assertIn("<html>", message.get_payload(1).get_payload()) def test_email_found_custom_from(self): - "Email is sent if a valid email address is provided for password reset when a custom from_email is provided." + """ + Email is sent if a valid email address is provided for password reset + when a custom from_email is provided. + """ response = self.client.post( "/password_reset_from_email/", {"email": "staffmember@example.com"} ) diff --git a/tests/auth_tests/urls.py b/tests/auth_tests/urls.py index 9f8cd14bdd..99fa22e4f4 100644 --- a/tests/auth_tests/urls.py +++ b/tests/auth_tests/urls.py @@ -148,7 +148,9 @@ urlpatterns = auth_urlpatterns + [ "reset/post_reset_login_custom_backend/<uidb64>/<token>/", views.PasswordResetConfirmView.as_view( post_reset_login=True, - post_reset_login_backend="django.contrib.auth.backends.AllowAllUsersModelBackend", + post_reset_login_backend=( + "django.contrib.auth.backends.AllowAllUsersModelBackend" + ), ), ), path("reset/missing_parameters/", views.PasswordResetConfirmView.as_view()), |