Changeset 8542
- Timestamp:
- 08/25/08 11:55:57 (3 months ago)
- Files:
-
- django/trunk/django/contrib/auth/forms.py (modified) (1 diff)
- django/trunk/django/contrib/auth/tests/forms.py (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/contrib/auth/forms.py
r8214 r8542 31 31 32 32 def clean_password2(self): 33 password1 = self.cleaned_data ["password1"]33 password1 = self.cleaned_data.get("password1", "") 34 34 password2 = self.cleaned_data["password2"] 35 35 if password1 != password2: django/trunk/django/contrib/auth/tests/forms.py
r8162 r8542 5 5 >>> from django.contrib.auth.forms import PasswordChangeForm, SetPasswordForm 6 6 7 The user already exists.7 # The user already exists. 8 8 9 9 >>> user = User.objects.create_user("jsmith", "jsmith@example.com", "test123") … … 19 19 [u'A user with that username already exists.'] 20 20 21 The username contains invalid data.21 # The username contains invalid data. 22 22 23 23 >>> data = { … … 32 32 [u'This value must contain only letters, numbers and underscores.'] 33 33 34 The verification password is incorrect.34 # The verification password is incorrect. 35 35 36 36 >>> data = { … … 45 45 [u"The two password fields didn't match."] 46 46 47 The success case. 47 # One (or both) passwords weren't given 48 49 >>> data = {'username': 'jsmith2'} 50 >>> form = UserCreationForm(data) 51 >>> form.is_valid() 52 False 53 >>> form['password1'].errors 54 [u'This field is required.'] 55 >>> form['password2'].errors 56 [u'This field is required.'] 57 58 >>> data['password2'] = 'test123' 59 >>> form = UserCreationForm(data) 60 >>> form.is_valid() 61 False 62 >>> form['password1'].errors 63 [u'This field is required.'] 64 65 # The success case. 48 66 49 67 >>> data = { … … 58 76 <User: jsmith2> 59 77 60 The user submits an invalid username.78 # The user submits an invalid username. 61 79 62 80 >>> data = { … … 71 89 [u'Please enter a correct username and password. Note that both fields are case-sensitive.'] 72 90 73 The user is inactive.91 # The user is inactive. 74 92 75 93 >>> data = { … … 88 106 >>> user.save() 89 107 90 The success case108 # The success case 91 109 92 110 >>> form = AuthenticationForm(None, data) … … 96 114 [] 97 115 98 SetPasswordForm:116 ### SetPasswordForm: 99 117 100 The two new passwords do not match.118 # The two new passwords do not match. 101 119 102 120 >>> data = { … … 110 128 [u"The two password fields didn't match."] 111 129 112 The success case.130 # The success case. 113 131 114 132 >>> data = { … … 120 138 True 121 139 122 PasswordChangeForm:140 ### PasswordChangeForm: 123 141 124 142 The old password is incorrect. … … 135 153 [u'Your old password was entered incorrectly. Please enter it again.'] 136 154 137 The two new passwords do not match.155 # The two new passwords do not match. 138 156 139 157 >>> data = { … … 148 166 [u"The two password fields didn't match."] 149 167 150 The success case.168 # The success case. 151 169 152 170 >>> data = { … … 159 177 True 160 178 161 Regression test - check the order of fields:179 # Regression test - check the order of fields: 162 180 163 181 >>> PasswordChangeForm(user, {}).fields.keys()
