you can simply create a form on your test case and pass in dictionary
to mimic request parameters. I have blogged about it and you can find
it here:

http://www.reyjexter.com/post/unit-testing-django-component-example

-rey

On Oct 13, 9:30 am, 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.
>
> def testRegistrationFormCleanUsername(self):
>         data = {'username': 'test'}
>         form = RegistrationForm(data)
>         form.is_valid()
>
>         form.clean_username() # this method uses
> cleaned_data['username'] to get the form entry for username
>
> AttributeError: 'RegistrationForm' has no object 'cleaned_data'
>
> -meppum
--~--~---------~--~----~------------~-------~--~----~
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