summaryrefslogtreecommitdiff
path: root/django/contrib/auth/tests/forms.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/contrib/auth/tests/forms.py')
-rw-r--r--django/contrib/auth/tests/forms.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/django/contrib/auth/tests/forms.py b/django/contrib/auth/tests/forms.py
index 1e1e0a95d4..01f4995bb7 100644
--- a/django/contrib/auth/tests/forms.py
+++ b/django/contrib/auth/tests/forms.py
@@ -2,7 +2,7 @@
FORM_TESTS = """
>>> from django.contrib.auth.models import User
>>> from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
->>> from django.contrib.auth.forms import PasswordChangeForm
+>>> from django.contrib.auth.forms import PasswordChangeForm, SetPasswordForm
The user already exists.
@@ -95,6 +95,32 @@ True
>>> form.non_field_errors()
[]
+SetPasswordForm:
+
+The two new passwords do not match.
+
+>>> data = {
+... 'new_password1': 'abc123',
+... 'new_password2': 'abc',
+... }
+>>> form = SetPasswordForm(user, data)
+>>> form.is_valid()
+False
+>>> form["new_password2"].errors
+[u"The two password fields didn't match."]
+
+The success case.
+
+>>> data = {
+... 'new_password1': 'abc123',
+... 'new_password2': 'abc123',
+... }
+>>> form = SetPasswordForm(user, data)
+>>> form.is_valid()
+True
+
+PasswordChangeForm:
+
The old password is incorrect.
>>> data = {
@@ -132,4 +158,9 @@ The success case.
>>> form.is_valid()
True
+Regression test - check the order of fields:
+
+>>> PasswordChangeForm(user, {}).fields.keys()
+['old_password', 'new_password1', 'new_password2']
+
"""