def _checkCookie(self, expectedCookieValue, *args, **kwargs):
        """
        Call L{http.Request.addCookie} with C{*args} and C{**kwargs}, and check
        that the cookie value is equal to C{expectedCookieValue}.
        """
        channel = DummyChannel()
        req = http.Request(channel, False)
        req.addCookie(*args, **kwargs)
        self.assertEqual(req.cookies[0], expectedCookieValue)

        # Write nothing to make it produce the headers
        req.write(b"")
        writtenLines = channel.transport.written.getvalue().split(b"\r\n")

        # There should be one Set-Cookie header
        addCookieLines = [x for x in writtenLines
                          if x.startswith(b"Set-Cookie")]
        self.assertEqual(len(addCookieLines), 1)
        self.assertEqual(addCookieLines[0],
                         b"Set-Cookie: " + expectedCookieValue)

        Call L{http.Request.addCookie} with C{*args} and C{**kwargs}, and check
        that the cookie value is equal to C{expectedCookieValue}.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_http.py