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:
mdipierro
2017-04-28 08:04:56 -05:00
committed by GitHub
2 changed files with 3 additions and 3 deletions

View File

@@ -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

View File

@@ -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')