import unittest
from django.urls import reverse
from django.test import Client
class ViewTests(unittest.TestCase):
def setUp(self):
self.client = Client()
def test_View(self):
url = '/some-url/'
response = self.client.get(url)
products = response.context['products']
In the above test case, response.context is coming out to be None and hence, response.context['products'] is throwing exception. Whereas when I run the same on django admin shell, response.context has context object dict.
I am quite confused why this is happening. I couldn't find any reason in the django documents.
Would really appreciate if someone could help me with the above.
Thanks,