@@ -110,16 +110,31 @@ def test_textfield_hash(self):
110
110
leading/trailing whitespace so as to be friendly to broken browsers that
111
111
submit it (usually in textareas).
112
112
"""
113
- class TestForm (forms .Form ):
114
- name = forms .CharField ()
115
- bio = forms .CharField ()
113
+ f1 = HashTestForm ({'name' : 'joe' , 'bio' : 'Nothing notable.' })
114
+ f2 = HashTestForm ({'name' : ' joe' , 'bio' : 'Nothing notable. ' })
115
+ hash1 = utils .security_hash (None , f1 )
116
+ hash2 = utils .security_hash (None , f2 )
117
+ self .assertEqual (hash1 , hash2 )
116
118
117
- f1 = TestForm ({'name' : 'joe' , 'bio' : 'Nothing notable.' })
118
- f2 = TestForm ({'name' : ' joe' , 'bio' : 'Nothing notable. ' })
119
+ def test_empty_permitted (self ):
120
+ """
121
+ Regression test for #10643: the security hash should allow forms with
122
+ empty_permitted = True, or forms where data has not changed.
123
+ """
124
+ f1 = HashTestBlankForm ({})
125
+ f2 = HashTestForm ({}, empty_permitted = True )
119
126
hash1 = utils .security_hash (None , f1 )
120
127
hash2 = utils .security_hash (None , f2 )
121
128
self .assertEqual (hash1 , hash2 )
122
129
130
+ class HashTestForm (forms .Form ):
131
+ name = forms .CharField ()
132
+ bio = forms .CharField ()
133
+
134
+ class HashTestBlankForm (forms .Form ):
135
+ name = forms .CharField (required = False )
136
+ bio = forms .CharField (required = False )
137
+
123
138
#
124
139
# FormWizard tests
125
140
#
0 commit comments