On 28 February 2015 at 10:07, Pranjal Yadav <godricg...@gmail.com> wrote: > Abhilash, > > Thanks! it worked as you said. But renaming clean method is not > conventional. I changed the names and it looks like 'clean_password_repeat' > is good and that is the last input for that test as well, so I don't > understand why but that works.
When you are concerned with cleaning only single field, you use clean_<field> method to do that. But when you have more than one fields to clean you put that under form's clean method. Also, form's clean method is run only after all the clean_<field> methods have already run. Why does clean_repeat_password work? I don't understand! It may be because it just cleans 'repeat_password' , whose removal does not affect the creation of User model and hence your tests pass. For further details regarding this read here[1] > The 'except' part for 'clean_email' is not functioning as expected and I > have already written the validation tests for that part as well. Its not being used because it is not required at all. You don't have to clean an EmailField, django forms does that automatically. They are simply CharFields which are validated for email. And before you ask, I don't understand why coverage shows that the part before 'except' is being executed. My guess is that when email is valid, forms execute the `clean_email` method, but when its not, the ValidationError is raised before the execution reaches the `clean_email`. [1]: https://docs.djangoproject.com/en/1.7/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other -- thanks, Abhilash Raj _______________________________________________ Mailman-Developers mailing list Mailman-Developers@python.org https://mail.python.org/mailman/listinfo/mailman-developers Mailman FAQ: http://wiki.list.org/x/AgA3 Searchable Archives: http://www.mail-archive.com/mailman-developers%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-developers/archive%40jab.org Security Policy: http://wiki.list.org/x/QIA9