Hi Russ, To expand this question. Do we use unittest for testing forms? Because from what I see in the code, doctest only tests your model. CMIIW.
Kind Regards, On Fri, Jul 17, 2009 at 10:11 AM, Russell Keith-Magee < freakboy3...@gmail.com> wrote: > > On Thu, Jul 16, 2009 at 10:46 PM, Joshua Russo<josh.r.ru...@gmail.com> > wrote: > > > > I want to test my forms but I'm not sure the best way to go about it. > > It seems like it might be similar to views but I can't find much > > discussion of form testing in any of the discussions about unit > > testing. > > > > Any suggestions are much appreciated. > > Well, a Form is just a class with a bunch of member functions - in > your views you instantiate instances of the form and give it data, > call is_valid() to validate and clean data. > > So a test is exactly that. Instantiate your form, give it some sample > data, and assert that the data has either thrown an error (i.e., that > is_valid() == False and form.errors is populated), or that > form.cleaned_data contains the right output. > > Keep in mind that you don't need to test the core behaviour - Django's > test suite will check that a simple integer field will reject > character input, etc. All you need to test is your own local > extensions, like clean_* methods. > > Yours > Russ Magee %-) > > -- http://blog.scrum8.com http://twitter.com/scrum8 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---