jeudi 15 novembre 2018

Django test: How to get the html string from a HTTPResponseRedirect object

I have a test in which the view redirects using HttpRepsonseRedirect(). In my test I pass a dict to a POST request which goes through this HttpResponseRedirect.

data = {...data...}
response = self.client.post(url, data)

How do I check if strings are in the response HTML? I cant do:

self.assertContains(response, 'my_string')

or

self.assertIn(response, 'my_string')

Is there a way of accessing the HTML as a string from this response?

Aucun commentaire:

Enregistrer un commentaire