From: Chase Sterling Date: Fri, 26 Apr 2013 02:32:03 +0000 (-0400) Subject: Add test for session cookiejars other than RequestsCookieJar X-Git-Tag: v1.2.1~6^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1866f7596e2c9e20dddf5d8c570c44e496a71c57;p=services%2Fpython-requests.git Add test for session cookiejars other than RequestsCookieJar --- diff --git a/test_requests.py b/test_requests.py index e4c38c4..3f4405c 100644 --- a/test_requests.py +++ b/test_requests.py @@ -4,6 +4,7 @@ """Tests for Requests.""" from __future__ import division +import cookielib import json import os import unittest @@ -12,6 +13,7 @@ import pickle import requests from requests.auth import HTTPDigestAuth from requests.compat import str +from requests.cookies import cookiejar_from_dict try: import StringIO @@ -137,6 +139,17 @@ class RequestsTestCase(unittest.TestCase): ) assert 'foo' not in s.cookies + def test_generic_cookiejar_works(self): + cj = cookielib.CookieJar() + cookiejar_from_dict({'foo': 'bar'}, cj) + s = requests.session() + s.cookies = cj + r = s.get(httpbin('cookies')) + # Make sure the cookie was sent + assert r.json()['cookies']['foo'] == 'bar' + # Make sure the session cj is still the custom one + assert s.cookies is cj + def test_user_agent_transfers(self): heads = {