I'm fairly new to Django, but seem to be getting the hang of it.
I do have a small issue that's been bugging me a bit with the test
client: I've been writing tests for a form on a small site using the
TestClient. When I test for invalid data in the form I'm getting odd
errors. The problem seems to be that I'm passing the form to the
template in a dictionary, like so:
context['feedback'] = {
'form' : ContactUsForm(),
'message' : "Thanks for the feedback!",
'with_email' : True
}
The template adds the message and does a bit of special processing if
the 'with_email' key is set, but nothing fancy.
When I try and run the following line in a test though
self.assertFormError(response, 'feedback.form', 'reply_to', [u"Enter a
valid e-mail address."])
I get this error
"AssertionError: The form 'contactus.form' was not used to render
the response"
I tried different approaches to the form name ('form' or 'contactus')
but each generated an error
If I separate the form out from the dictionary however, the test
works, so it appears that it's the secondary lookup that this
assertion cannot handle. Does anyone know if that's correct, and/or if
there's a work-around or something I'm doing wrong? I'd rather not
take apart the dictionary just for the sake of getting the tests to
run (that seems a bit backward) but I also really like having a test
suite I can rely on.
Any ideas or suggestions greatly appreciated.
Thanks
Ian.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---