I have a view that sets a cookie using response.set_cookie
method. I would like to test if the cookie is being set in a TestCase
.
According to docs, the cookie should be accessible in the client object, but client.cookies.items
returns an empty list. The cookie is being correctly set in the browser.
Any ideas?
EDIT: adding test case
>>> response = self.client.get(url)
>>> self.client.cookies.items()
[]
The last statement returns an empty list.
You need to use the response's client instance:
response = self.client.get(url)
response.client.cookies.items()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With