On Sun, Oct 12, 2008 at 8:30 PM, meppum <[EMAIL PROTECTED]> wrote:
> I would like to be able to unit test my forms. Specifically, I'd like
> to be able to test individual clean methods, but I get errors when I
> try to call cleaned methods directly. Below is an example of testing a
> registration form. I couldn't find any documentation on this.

First, create an instance of the form using a dictionary of data which
should fail, then check that is_valid() is False and inspect the error
dictionary to make sure it got the right message.

Then, create an instance using a dictionary that should pass, and
check that is_valid() is True.

django-registration does this in its unit-test suite (form tests start
at line 145):

http://www.bitbucket.org/ubernostrum/django-registration/src/tip/registration/tests.py


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to