Skip to content
Myr

preserve python2-like dict API for RequestCookieJar

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Konstantin Podshumok · committed by Konstantin Podshumok · parent 537def4 · Browse files · 2 files+7 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+7 added−13 removed

  • other:+7 added−13 removed

2 files+7 added−13 removed

modified:requests/cookies.py+4 added-13 removed
6 unmodified lines
7"""89import time10import collections11from .compat import cookielib, urlparse, urlunparse, Morsel, is_py311from .compat import cookielib, urlparse, urlunparse, Morsel1213try:14 import threading15 # grr, pyflakes: this fixes "redefinition of unused 'threading'"
190 unmodified lines
206207 def keys(self):208 """Dict-like keys() that returns a list of names of cookies from the jar.209 See values() and items()."""210 if is_py3:211 return self.iterkeys()212 else:213 return list(self.iterkeys())210 return list(self.iterkeys())211212 def itervalues(self):213 """Dict-like itervalues() that returns an iterator of values of cookies from the jar.214 See iterkeys() and iteritems()."""
2 unmodified lines
217218 def values(self):219 """Dict-like values() that returns a list of values of cookies from the jar.220 See keys() and items()."""224 if is_py3:225 return self.itervalues()226 else:227 return list(self.itervalues())221 return list(self.itervalues())222223 def iteritems(self):224 """Dict-like iteritems() that returns an iterator of name-value tuples from the jar.225 See iterkeys() and itervalues()."""
3 unmodified lines
229 def items(self):230 """Dict-like items() that returns a list of name-value tuples from the jar.231 See keys() and values(). Allows client-code to call "dict(RequestsCookieJar)232 and get a vanilla python dict of key value pairs."""239 if is_py3:240 return self.iteritems()241 else:242 return list(self.iteritems())233 return list(self.iteritems())234235 def list_domains(self):236 """Utility method to list all the domains in the jar."""237 domains = []
217 unmodified lines
modified:test_requests.py+3 added
591 unmodified lines
592 assert d1['some_cookie'] == 'some_value'593 assert d2['some_cookie'] == 'some_value'594 assert d3['some_cookie'] == 'some_value'595596 keys = jar.keys()597 assert list(keys) == list(keys)598599 def test_time_elapsed_blank(self):600 r = requests.get(httpbin('get'))601 td = r.elapsed602 total_seconds = ((td.microseconds + (td.seconds + td.days * 24 * 3600)
492 unmodified lines