summaryrefslogtreecommitdiff
path: root/tests/test_utils.py
diff options
context:
space:
mode:
authorNate Prewitt <Nate.Prewitt@gmail.com>2016-10-27 13:22:45 -0600
committerNate Prewitt <Nate.Prewitt@gmail.com>2016-10-27 13:22:45 -0600
commit390a499e81cebe835c1e35b9c917840db85a4ce4 (patch)
treed1899a5e6ed33a6689fad8fec586d34a75296e0b /tests/test_utils.py
parentdfd85f2099117adf8058d3f71e196cbfc5254760 (diff)
downloadpython-requests-390a499e81cebe835c1e35b9c917840db85a4ce4.tar.gz
test different CookieJar types for add_dict_to_cookiejar
Diffstat (limited to 'tests/test_utils.py')
-rw-r--r--tests/test_utils.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 7e0b4f28..639729ca 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -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
@@ -501,3 +502,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