Skip to content
Myr

Merge pull request #3032 from davidsoncasey/master

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

Changes for #3028

authored by Cory Benfield · committed by Cory Benfield · parents 4618423, f74a670 · Browse files · 2 files+38 added−0 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+38 added−0 removed

  • tests:+32 added−0 removed
  • other:+6 added−0 removed

2 files+38 added−0 removed

modified:requests/cookies.py+6 added
275 unmodified lines
276 or cookie.path == path):277 dictionary[cookie.name] = cookie.value278 return dictionary279280 def __contains__(self, name):281 try:282 return super(RequestsCookieJar, self).__contains__(name)283 except CookieConflictError:284 return True285286 def __getitem__(self, name):287 """Dict-like __getitem__() for compatibility with client code. Throws288 exception if there are more than one cookie with name. In that case,289 use the more explicit get() method instead.
204 unmodified lines
modified:tests/test_requests.py+32 added
752 unmodified lines
753 assert items == list(items)754 # make sure one can use items multiple times755 assert list(items) == list(items)756757 def test_cookie_duplicate_names_different_domains(self):758 key = 'some_cookie'759 value = 'some_value'760 domain1 = 'test1.com'761 domain2 = 'test2.com'762763 jar = requests.cookies.RequestsCookieJar()764 jar.set(key, value, domain=domain1)765 jar.set(key, value, domain=domain2)766 assert key in jar767 items = jar.items()768 assert len(items) == 2769770 # Verify that CookieConflictError is raised if domain is not specified771 with pytest.raises(requests.cookies.CookieConflictError):772 jar.get(key)773774 # Verify that CookieConflictError is not raised if domain is specified775 cookie = jar.get(key, domain=domain1)776 assert cookie == value777778 def test_cookie_duplicate_names_raises_cookie_conflict_error(self):779 key = 'some_cookie'780 value = 'some_value'781 path = 'some_path'782783 jar = requests.cookies.RequestsCookieJar()784 jar.set(key, value, path=path)785 jar.set(key, value)786 with pytest.raises(requests.cookies.CookieConflictError):787 jar.get(key)788789 def test_time_elapsed_blank(self, httpbin):790 r = requests.get(httpbin('get'))791 td = r.elapsed792 total_seconds = ((td.microseconds + (td.seconds + td.days * 24 * 3600)
694 unmodified lines