Mocking cookies with responses
<p>I have a piece of code that deals with cookies being set by the server as a response of an HTTP response. I'm attempting to test it using <code>responses</code>, like so:</p>

<pre><code>responses.add(responses.GET, "http://invalid/cookies",
              adding_headers = {
                  "Set-Cookie": "foo=bar; " +
                                "domain=.invalid; " +
                                "expires=Fri, 01-Jan-2055 00:00:00 GMT; " +
                                "path=/; " +
                                "HttpOnly",
              })
</code></pre>

<p>I would then expect this to return my cookie, but no such luck.</p>

<pre><code>session = requests.Session()
session.get('http://invalid/cookies')
session.cookies['foo'] # KeyError
</code></pre>

<p>Indeed, this works outside of the context of <code>responses.activate</code>:</p>

<pre><code>session = requests.Session()
session.get('https://httpbin.org/cookies/set?foo=bar')
session.cookies['foo'] # 'bar'
</code></pre>

<p>How can I mock cookies with <code>responses</code>?</p>