diff options
| author | django-bot <ops@djangoproject.com> | 2025-07-22 20:41:41 -0700 |
|---|---|---|
| committer | nessita <124304+nessita@users.noreply.github.com> | 2025-07-23 20:17:55 -0300 |
| commit | 69a93a88edb56ba47f624dac7a21aacc47ea474f (patch) | |
| tree | f57507a4435d032493cae40e06ecb254790b67b2 /tests/auth_tests | |
| parent | 55b0cc21310b76ce4018dd793ba50556eaf0af06 (diff) | |
Refs #36500 -- Rewrapped long docstrings and block comments via a script.
Rewrapped long docstrings and block comments to 79 characters + newline
using script from https://github.com/medmunds/autofix-w505.
Diffstat (limited to 'tests/auth_tests')
| -rw-r--r-- | tests/auth_tests/test_auth_backends.py | 12 | ||||
| -rw-r--r-- | tests/auth_tests/test_basic.py | 5 | ||||
| -rw-r--r-- | tests/auth_tests/test_context_processors.py | 3 | ||||
| -rw-r--r-- | tests/auth_tests/test_forms.py | 9 | ||||
| -rw-r--r-- | tests/auth_tests/test_hashers.py | 3 | ||||
| -rw-r--r-- | tests/auth_tests/test_management.py | 10 | ||||
| -rw-r--r-- | tests/auth_tests/test_remote_user.py | 6 | ||||
| -rw-r--r-- | tests/auth_tests/test_validators.py | 3 | ||||
| -rw-r--r-- | tests/auth_tests/test_views.py | 20 |
9 files changed, 48 insertions, 23 deletions
diff --git a/tests/auth_tests/test_auth_backends.py b/tests/auth_tests/test_auth_backends.py index 32fb092cf4..0ba169249b 100644 --- a/tests/auth_tests/test_auth_backends.py +++ b/tests/auth_tests/test_auth_backends.py @@ -457,7 +457,9 @@ class BaseModelBackendTest: PASSWORD_HASHERS=["auth_tests.test_auth_backends.CountingMD5PasswordHasher"] ) def test_authentication_timing(self): - """Hasher is run once regardless of whether the user exists. Refs #20760.""" + """ + Hasher is run once regardless of whether the user exists. Refs #20760. + """ # Re-set the password, because this tests overrides PASSWORD_HASHERS self.user.set_password("test") self.user.save() @@ -875,7 +877,8 @@ class InActiveUserBackendTest(TestCase): class PermissionDeniedBackend: """ - Always raises PermissionDenied in `authenticate`, `has_perm` and `has_module_perms`. + Always raises PermissionDenied in `authenticate`, `has_perm` and + `has_module_perms`. """ def authenticate(self, request, username=None, password=None): @@ -920,7 +923,10 @@ class PermissionDeniedBackendTest(TestCase): @modify_settings(AUTHENTICATION_BACKENDS={"prepend": backend}) def test_permission_denied(self): - "user is not authenticated after a backend raises permission denied #2550" + """ + user is not authenticated after a backend raises permission denied + #2550 + """ self.assertIsNone(authenticate(username="test", password="test")) # user_login_failed signal is sent. self.assertEqual( diff --git a/tests/auth_tests/test_basic.py b/tests/auth_tests/test_basic.py index 8d54e187fc..85155dad90 100644 --- a/tests/auth_tests/test_basic.py +++ b/tests/auth_tests/test_basic.py @@ -112,7 +112,10 @@ class BasicTestCase(TestCase): @override_settings(AUTH_USER_MODEL="badsetting") def test_swappable_user_bad_setting(self): - "The alternate user setting must point to something in the format app.model" + """ + The alternate user setting must point to something in the format + app.model + """ msg = "AUTH_USER_MODEL must be of the form 'app_label.model_name'" with self.assertRaisesMessage(ImproperlyConfigured, msg): get_user_model() diff --git a/tests/auth_tests/test_context_processors.py b/tests/auth_tests/test_context_processors.py index 7e6c6a556e..cebc1108dc 100644 --- a/tests/auth_tests/test_context_processors.py +++ b/tests/auth_tests/test_context_processors.py @@ -145,7 +145,8 @@ class AuthContextProcessorTests(TestCase): # bug #12037 is tested by the {% url %} in the template: self.assertContains(response, "url: /userpage/super/") - # A Q() comparing a user and with another Q() (in an AND or OR fashion). + # A Q() comparing a user and with another Q() (in an AND or OR + # fashion). Q(user=response.context["user"]) & Q(someflag=True) # Tests for user equality. This is hard because User defines diff --git a/tests/auth_tests/test_forms.py b/tests/auth_tests/test_forms.py index ebfaa8b051..735ac1d237 100644 --- a/tests/auth_tests/test_forms.py +++ b/tests/auth_tests/test_forms.py @@ -576,7 +576,8 @@ class AuthenticationFormTest(TestDataMixin, TestCase): ] ) def test_custom_login_allowed_policy(self): - # The user is inactive, but our custom form policy allows them to log in. + # The user is inactive, but our custom form policy allows them to log + # in. data = { "username": "inactive", "password": "password", @@ -1322,9 +1323,9 @@ class PasswordResetFormTest(TestDataMixin, TestCase): def test_save_plaintext_email(self): """ - Test the PasswordResetForm.save() method with no html_email_template_name - parameter passed in. - Test to ensure original behavior is unchanged after the parameter was added. + Test the PasswordResetForm.save() method with no + html_email_template_name parameter passed in. Test to ensure original + behavior is unchanged after the parameter was added. """ (user, username, email) = self.create_dummy_user() form = PasswordResetForm({"email": email}) diff --git a/tests/auth_tests/test_hashers.py b/tests/auth_tests/test_hashers.py index ba7131406b..910238d2f5 100644 --- a/tests/auth_tests/test_hashers.py +++ b/tests/auth_tests/test_hashers.py @@ -379,7 +379,8 @@ class TestUtilsHashPass(SimpleTestCase): # Revert to the old iteration count and ... hasher.iterations = old_iterations - # ... check if the password would get updated to the new iteration count. + # ... check if the password would get updated to the new iteration + # count. self.assertTrue(check_password("letmein", encoded, setter)) self.assertTrue(state["upgraded"]) finally: diff --git a/tests/auth_tests/test_management.py b/tests/auth_tests/test_management.py index 9f12e631cc..0701ac2d68 100644 --- a/tests/auth_tests/test_management.py +++ b/tests/auth_tests/test_management.py @@ -200,7 +200,10 @@ class ChangepasswordManagementCommandTestCase(TestCase): @mock.patch.object(changepassword.Command, "_get_pass", return_value="not qwerty") def test_that_changepassword_command_changes_joes_password(self, mock_get_pass): - "Executing the changepassword management command should change joe's password" + """ + Executing the changepassword management command should change joe's + password + """ self.assertTrue(self.user.check_password("qwerty")) call_command("changepassword", username="joe", stdout=self.stdout) @@ -413,7 +416,10 @@ class CreatesuperuserManagementCommandTestCase(TestCase): @override_settings(AUTH_USER_MODEL="auth_tests.CustomUser") def test_swappable_user_missing_required_field(self): - "A Custom superuser won't be created when a required field isn't provided" + """ + A Custom superuser won't be created when a required field isn't + provided + """ # We can use the management command to create a superuser # We skip validation because the temporary substitution of the # swappable User model messes with validation. diff --git a/tests/auth_tests/test_remote_user.py b/tests/auth_tests/test_remote_user.py index 4b5902b586..c871ea7dc8 100644 --- a/tests/auth_tests/test_remote_user.py +++ b/tests/auth_tests/test_remote_user.py @@ -243,7 +243,8 @@ class RemoteUserTest(TestCase): # Known user authenticates response = self.client.get("/remote_user/", **{self.header: self.known_user}) self.assertEqual(response.context["user"].username, "knownuser") - # During the session, the REMOTE_USER header disappears. Should trigger logout. + # During the session, the REMOTE_USER header disappears. Should trigger + # logout. response = self.client.get("/remote_user/") self.assertTrue(response.context["user"].is_anonymous) # verify the remoteuser middleware will not remove a user @@ -262,7 +263,8 @@ class RemoteUserTest(TestCase): "/remote_user/", **{self.header: self.known_user} ) self.assertEqual(response.context["user"].username, "knownuser") - # During the session, the REMOTE_USER header disappears. Should trigger logout. + # During the session, the REMOTE_USER header disappears. Should trigger + # logout. response = await self.async_client.get("/remote_user/") self.assertTrue(response.context["user"].is_anonymous) # verify the remoteuser middleware will not remove a user diff --git a/tests/auth_tests/test_validators.py b/tests/auth_tests/test_validators.py index fdbf495ff5..2a3a93efe8 100644 --- a/tests/auth_tests/test_validators.py +++ b/tests/auth_tests/test_validators.py @@ -114,7 +114,8 @@ class PasswordValidationTest(SimpleTestCase): help_text = password_validators_help_text_html([AmpersandValidator()]) self.assertEqual(help_text, "<ul><li>Must contain &</li></ul>") - # help_text is marked safe and therefore unchanged by conditional_escape(). + # help_text is marked safe and therefore unchanged by + # conditional_escape(). self.assertEqual(help_text, conditional_escape(help_text)) @override_settings(AUTH_PASSWORD_VALIDATORS=[]) diff --git a/tests/auth_tests/test_views.py b/tests/auth_tests/test_views.py index e6419de8e6..0a4f7d28c8 100644 --- a/tests/auth_tests/test_views.py +++ b/tests/auth_tests/test_views.py @@ -153,8 +153,8 @@ class PasswordResetTest(AuthViewsTestCase): self.assertEqual(len(mail.outbox), 1) self.assertIn("http://", mail.outbox[0].body) self.assertEqual(settings.DEFAULT_FROM_EMAIL, mail.outbox[0].from_email) - # optional multipart text/html email has been added. Make sure original, - # default functionality is 100% the same + # optional multipart text/html email has been added. Make sure + # original, default functionality is 100% the same self.assertFalse(mail.outbox[0].message().is_multipart()) def test_extra_email_context(self): @@ -209,8 +209,8 @@ class PasswordResetTest(AuthViewsTestCase): # the colon is interpreted as part of a username for login purposes, # making 'evil.com' the request domain. Since HTTP_HOST is used to # produce a meaningful reset URL, we need to be certain that the - # HTTP_HOST header isn't poisoned. This is done as a check when get_host() - # is invoked, but we check here as a practical consequence. + # HTTP_HOST header isn't poisoned. This is done as a check when + # get_host() is invoked, but we check here as a practical consequence. with self.assertLogs("django.security.DisallowedHost", "ERROR"): response = self.client.post( "/password_reset/", @@ -223,7 +223,10 @@ class PasswordResetTest(AuthViewsTestCase): # Skip any 500 handler action (like sending more mail...) @override_settings(DEBUG_PROPAGATE_EXCEPTIONS=True) def test_poisoned_http_host_admin_site(self): - "Poisoned HTTP_HOST headers can't be used for reset emails on admin views" + """ + Poisoned HTTP_HOST headers can't be used for reset emails on admin + views + """ with self.assertLogs("django.security.DisallowedHost", "ERROR"): response = self.client.post( "/admin_password_reset/", @@ -733,7 +736,8 @@ class SessionAuthenticationTests(AuthViewsTestCase): def test_user_password_change_updates_session(self): """ #21649 - Ensure contrib.auth.views.password_change updates the user's - session auth hash after a password change so the session isn't logged out. + session auth hash after a password change so the session isn't logged + out. """ self.login() original_session_key = self.client.session.session_key @@ -901,8 +905,8 @@ class LoginTest(AuthViewsTestCase): def test_session_key_flushed_on_login(self): """ To avoid reusing another user's session, ensure a new, empty session is - created if the existing session corresponds to a different authenticated - user. + created if the existing session corresponds to a different + authenticated user. """ self.login() original_session_key = self.client.session.session_key |
