Wednesday, September 7, 2011

Re: In unitTest, GET Formset returns 302 instead of 200

On 7 September 2011 11:52, MATHIEU <chenxinlei12345678@gmail.com> wrote:
For the GET method, I have tried the following code:
================================
   def test_patron_phone_get_form(self):
           self.client.login(usernamer='alex.wg@e.com',
password='alex')
           response = self.client.get(reverse('patron_edit_phone'))
           self.assertEquals(response.status_code, 200)
================================
But this doesn't work. Instead of getting a status_code=200, I get a
status_code=302. Why?

If this is a cut'n'paste of your code, you have a typo in the self.client.login() call - you're passing "usernamer" not "username" 

Malcolm

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment