On Jul 16, 11:11 pm, Russell Keith-Magee <[email protected]>
wrote:
> On Thu, Jul 16, 2009 at 10:46 PM, Joshua Russo<[email protected]> 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 %-)

Thanks. I'm guess I need to take a closer look at the forms
functionality. I don't think I'm using it properly. This is my first
Django project and I guess I don't always know enough of what I'm
asking about to ask a full question.

Thanks for the input.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to