@Malcolm, Sorry It should be some bad pastes :( Finally, I have solved the problem using the following 2 lines:
c = Client() c.login(username='[email protected]', password='alex') In fact, I can't login in with the following code self.client.login(username='[email protected]', password='alex') I don't know why. So if anyone knows the reason, why not share it without us :) Xinlei On 7 September 2011 16:44, Malcolm Box <[email protected]> wrote: > On 7 September 2011 11:52, MATHIEU <[email protected]> wrote: > >> For the GET method, I have tried the following code: >> ================================ >> def test_patron_phone_get_form(self): >> self.client.login(usernamer='[email protected]', >> 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 [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. > -- 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.

