assertEqual is a Python TestCase method for checking that two values match. If they differ, it raises an exception and marks the test as failed. section 8.2
In a Django test, compare an expected result with a response value, commonly after the test client requests a URL. Putting the expected value first makes failures easier to read. section 8.2
Checking a view response
response = self.client.get("/credits/") self.assertEqual(200, response.status_code) The test expects the credits view to return HTTP 200. Changing 200 to 42 produces a failure such as AssertionError: 42 != 200, with a traceback identifying the test line. section 8.2
Listing 8.1 A test case for the credits() view
# home/tests.py
from django.test import TestCase #1
class TestHome(TestCase): #2
def test_credits(self): #3
response = self.client.get("/credits/") #4
self.assertEqual(200, response.status_code) #5
Use the complete test case to connect assertEqual with TestCase inheritance, the Django test client, URL routing, and response status codes. section 8.2

