From 1866f7596e2c9e20dddf5d8c570c44e496a71c57 Mon Sep 17 00:00:00 2001 From: Chase Sterling Date: Thu, 25 Apr 2013 22:32:03 -0400 Subject: [PATCH] Add test for session cookiejars other than RequestsCookieJar --- test_requests.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 = { -- 2.34.1