summaryrefslogtreecommitdiff
path: root/tests/auth_tests
diff options
context:
space:
mode:
authorNatalia <124304+nessita@users.noreply.github.com>2024-02-20 12:12:37 -0300
committerNatalia <124304+nessita@users.noreply.github.com>2024-02-20 12:12:37 -0300
commit8a757244f9e50c4d076e559e4b74b9d83ab089b6 (patch)
tree5db38e4b9686cc510746f25cca56137bac2600d0 /tests/auth_tests
parentf64c528c17af91333fc6e96d91b5f13c0fb647d8 (diff)
Refs #34429 -- Defined test user with unusable password for auth forms tests.
Diffstat (limited to 'tests/auth_tests')
-rw-r--r--tests/auth_tests/test_forms.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/tests/auth_tests/test_forms.py b/tests/auth_tests/test_forms.py
index 14604cd2e6..7e78006429 100644
--- a/tests/auth_tests/test_forms.py
+++ b/tests/auth_tests/test_forms.py
@@ -16,6 +16,7 @@ from django.contrib.auth.forms import (
UserCreationForm,
UsernameField,
)
+from django.contrib.auth.hashers import make_password
from django.contrib.auth.models import User
from django.contrib.auth.signals import user_login_failed
from django.contrib.sites.models import Site
@@ -54,6 +55,9 @@ class TestDataMixin:
cls.u4 = User.objects.create(username="empty_password", password="")
cls.u5 = User.objects.create(username="unmanageable_password", password="$")
cls.u6 = User.objects.create(username="unknown_password", password="foo$bar")
+ cls.u7 = User.objects.create(
+ username="unusable_password", password=make_password(None)
+ )
class BaseUserCreationFormTest(TestDataMixin, TestCase):
@@ -918,9 +922,7 @@ class UserChangeFormTest(TestDataMixin, TestCase):
MyUserForm({})
def test_unusable_password(self):
- user = User.objects.get(username="empty_password")
- user.set_unusable_password()
- user.save()
+ user = User.objects.get(username="unusable_password")
form = UserChangeForm(instance=user)
self.assertIn(_("No password set."), form.as_table())