mardi 30 juin 2015

Django Response has no content - How to debug?

I am trying to add testing to my Django 1.8 application and am running into trouble with a test to make sure registration goes through successfully. I don't know how to debug to see what is wrong.

I make the following call in my code after setting up the Client.

class LoginTests(TestCase):
    def setUp(self):
        self.client = Client()

    def test_user_can_select_vegetarian_on_account_create(self):

        data = {'username': 'TestUser', 'password1':'pass', 'password2':'pass', 'email':'bad@email.com', 'is_admin':True}
        r = self.client.post('/register/', data)
        print(r.content)
        self.assertTrue(r.context is not None)
    print(list(User.objects.all()))

the print(r.content) just prints a blank, so nothing is coming back, although it is a response. When I look at the status code, I get a 302.

I am not sure how to see what is going wrong, so mostly I am just looking at how to debug this process. Print statements in the server code are not showing up so I am totally lost as to what is happening. Any ideas?

Aucun commentaire:

Enregistrer un commentaire