Merge pull request #1602 from leonelcamara/fix_webclientforget
Create a CookieJar on __init__ instead of creating a new one each post
This commit is contained in:
@@ -43,6 +43,7 @@ class WebClient(object):
|
||||
self.forms = {}
|
||||
self.history = []
|
||||
self.cookies = {}
|
||||
self.cookiejar = cookielib.CookieJar()
|
||||
self.default_headers = default_headers
|
||||
self.sessions = {}
|
||||
self.session_regex = session_regex and re.compile(session_regex)
|
||||
@@ -79,9 +80,8 @@ class WebClient(object):
|
||||
cookies = cookies or {}
|
||||
headers = headers or {}
|
||||
|
||||
cj = cookielib.CookieJar()
|
||||
args = [
|
||||
urllib2.HTTPCookieProcessor(cj),
|
||||
urllib2.HTTPCookieProcessor(self.cookiejar),
|
||||
urllib2.HTTPHandler(debuglevel=0)
|
||||
]
|
||||
# if required do basic auth
|
||||
|
||||
@@ -110,7 +110,7 @@ class TestWeb(LiveTest):
|
||||
self.assertTrue('Welcome Homer' in client.text)
|
||||
|
||||
client = WebClient('http://127.0.0.1:8000/admin/default/')
|
||||
client.post('index', data=dict(password='hello'))
|
||||
client.post('index', data=dict(password='testpass'))
|
||||
client.get('site')
|
||||
client.get('design/welcome')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user