'Assert that the C{responses} matches the C{expected} responses.
@type responses: C{bytes}
@param responses: The bytes sent in response to one or more requests.
@type expected: C{list} of C{tuple} of C{bytes}
@param expected: The expected values for the responses.  Each tuple
element of the list represents one response.  Each byte string
element of the tuple is a full header line without delimiter, except
for the last element which gives the full response body.'

def assertResponseEquals(self, responses, expected):

    for response in expected:
        (expectedHeaders, expectedContent) = (response[:(-1)], response[(-1)])
        expectedStatus = expectedHeaders[0]
        expectedHeaders = expectedHeaders[1:]
        (headers, rest) = responses.split('\r\n\r\n', 1)
        headers = headers.splitlines()
        status = headers.pop(0)
        self.assertEqual(expectedStatus, status)
        self.assertEqual(set(headers), set(expectedHeaders))
        content = rest[:len(expectedContent)]
        responses = rest[len(expectedContent):]
        self.assertEqual(content, expectedContent)
