made sessions.py to use that method when merging cookies.
if not isinstance(cookiejar, cookielib.CookieJar):
raise ValueError('You can only merge into CookieJar')
+ merged_cookie = RequestsCookieJar()
+ merged_cookie.update(cookiejar)
+
if isinstance(cookies, dict):
- cookiejar = cookiejar_from_dict(
- cookies, cookiejar=cookiejar, overwrite=False)
+ merged_cookie = cookiejar_from_dict(
+ cookies, cookiejar=merged_cookie, overwrite=False)
elif isinstance(cookies, cookielib.CookieJar):
- cookiejar.update(cookies)
+ merged_cookie.update(cookies)
- return cookiejar
+ return merged_cookie
cookies = cookiejar_from_dict(cookies)
# Merge with session cookies
- merged_cookies = RequestsCookieJar()
- merged_cookies.update(self.cookies)
- merged_cookies.update(cookies)
+ merged_cookies = merge_cookies(
+ merge_cookies(RequestsCookieJar(), self.cookies), cookies)
# Set environment's basic authentication if not explicitly set.
# 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
+ assert isinstance(s.cookies, cookielib.CookieJar)
+ assert s.cookies['foo'] == 'bar'
def test_param_cookiejar_works(self):
cj = cookielib.CookieJar()