17👍
✅
You are comparing two different instances of the EmployeeNameForm
, which is why the assertion fails.
If you just want to test that the context variable is indeed a EmployeeNameForm
then you can test it with assertIsInstance:
def test_CreateEmployeeProfileView_context(self):
response = self.client.get(reverse('create_employee_profile'))
self.assertIsInstance(response.context['name_form'], EmployeeNameForm)
Source:stackexchange.com