Merge pull request #3627 from nateprewitt/remove_update_call

remove RequestsCookieJar specific update call
This commit is contained in:
Cory Benfield
2016-10-27 20:53:18 +01:00
committed by GitHub
2 changed files with 18 additions and 4 deletions
+1 -3
View File
@@ -331,9 +331,7 @@ def add_dict_to_cookiejar(cj, cookie_dict):
:rtype: CookieJar
"""
cj2 = cookiejar_from_dict(cookie_dict)
cj.update(cj2)
return cj
return cookiejar_from_dict(cookie_dict, cj)
def get_encodings_from_content(content):
+17 -1
View File
@@ -4,6 +4,7 @@ from io import BytesIO
import pytest
from requests import compat
from requests.cookies import RequestsCookieJar, cookiejar_from_dict
from requests.structures import CaseInsensitiveDict
from requests.utils import (
address_in_network, dotted_netmask,
@@ -15,7 +16,7 @@ from requests.utils import (
requote_uri, select_proxy, should_bypass_proxies, super_len,
to_key_val_list, to_native_string,
unquote_header_value, unquote_unreserved,
urldefragauth)
urldefragauth, add_dict_to_cookiejar)
from .compat import StringIO, cStringIO
@@ -513,3 +514,18 @@ def test_should_bypass_proxies(url, expected, monkeypatch):
monkeypatch.setenv('no_proxy', '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1')
monkeypatch.setenv('NO_PROXY', '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1')
assert should_bypass_proxies(url) == expected
@pytest.mark.parametrize(
'cookiejar', (
compat.cookielib.CookieJar(),
RequestsCookieJar()
))
def test_add_dict_to_cookiejar(cookiejar):
"""Ensure add_dict_to_cookiejar works for
non-RequestsCookieJar CookieJars
"""
cookiedict = {'test': 'cookies',
'good': 'cookies'}
cj = add_dict_to_cookiejar(cookiejar, cookiedict)
cookies = dict((cookie.name, cookie.value) for cookie in cj)
assert cookiedict == cookies