diff options
| author | Gregory P. Smith <greg@mad-scientist.com> | 2010-07-25 20:00:02 (GMT) |
|---|---|---|
| committer | Gregory P. Smith <greg@mad-scientist.com> | 2010-07-25 20:00:02 (GMT) |
| commit | 034ec7855685f4761abfcc8dd9f2e11579976e07 (patch) | |
| tree | 342e0a46b32a1d9d7e54a326317e8ee1839182bd /Lib/test/test_cookielib.py | |
| parent | 7c973454a9ba776d153196c2a4f05d8234ced542 (diff) | |
| download | cpython-034ec7855685f4761abfcc8dd9f2e11579976e07.zip cpython-034ec7855685f4761abfcc8dd9f2e11579976e07.tar.gz cpython-034ec7855685f4761abfcc8dd9f2e11579976e07.tar.bz2 | |
Merged revisions 83145 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/release27-maint
........
r83145 | gregory.p.smith | 2010-07-25 12:11:36 -0700 (Sun, 25 Jul 2010) | 3 lines
Fixes issue #3704: cookielib was not properly handling URLs with a / in the
parameters.
........
Diffstat (limited to 'Lib/test/test_cookielib.py')
| -rw-r--r-- | Lib/test/test_cookielib.py | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/Lib/test/test_cookielib.py b/Lib/test/test_cookielib.py index 8394f8e..1292b26 100644 --- a/Lib/test/test_cookielib.py +++ b/Lib/test/test_cookielib.py @@ -1,11 +1,16 @@ # -*- coding: latin-1 -*- """Tests for cookielib.py.""" -import re, os, time +import cookielib +import os +import re +import time + from unittest import TestCase from test import test_support + class DateTimeTests(TestCase): def test_time2isoz(self): @@ -563,6 +568,16 @@ class CookieTests(TestCase): interact_netscape(c, "http://www.acme.com/blah/rhubarb/", 'eggs="bar"') self.assert_("/blah/rhubarb" in c._cookies["www.acme.com"]) + def test_default_path_with_query(self): + cj = cookielib.CookieJar() + uri = "http://example.com/?spam/eggs" + value = 'eggs="bar"' + interact_netscape(cj, uri, value) + # default path does not include query, so is "/", not "/?spam" + self.assert_("/" in cj._cookies["example.com"]) + # cookie is sent back to the same URI + self.assertEquals(interact_netscape(cj, uri), value) + def test_escape_path(self): from cookielib import escape_path cases = [ @@ -591,15 +606,14 @@ class CookieTests(TestCase): from urllib2 import Request from cookielib import request_path # with parameters - req = Request("http://www.example.com/rheum/rhaponicum;" + req = Request("http://www.example.com/rheum/rhaponticum;" "foo=bar;sing=song?apples=pears&spam=eggs#ni") - self.assertEquals(request_path(req), "/rheum/rhaponicum;" - "foo=bar;sing=song?apples=pears&spam=eggs#ni") + self.assertEquals(request_path(req), + "/rheum/rhaponticum;foo=bar;sing=song") # without parameters - req = Request("http://www.example.com/rheum/rhaponicum?" + req = Request("http://www.example.com/rheum/rhaponticum?" "apples=pears&spam=eggs#ni") - self.assertEquals(request_path(req), "/rheum/rhaponicum?" - "apples=pears&spam=eggs#ni") + self.assertEquals(request_path(req), "/rheum/rhaponticum") # missing final slash req = Request("http://www.example.com") self.assertEquals(request_path(req), "/") |
