The request object will not be present inside your test case until you make an HTTP request using one of the get , post , delete , put , etc. methods.
For example, your code will work if you were preceded by request.cookies['foo'] = 'bar' using get root_path .
source share