summaryrefslogtreecommitdiff
path: root/paste/tests
diff options
context:
space:
mode:
authorianb <devnull@localhost>2005-05-13 21:14:33 +0000
committerianb <devnull@localhost>2005-05-13 21:14:33 +0000
commit426fea4d2bfa614e7247459ac80818b3c57de523 (patch)
treee523629a4ad84c853798e935901ac1aa9d8d32bc /paste/tests
parent94a26b334072b4003b082a20f2c5b513ecbeae9f (diff)
downloadpaste-426fea4d2bfa614e7247459ac80818b3c57de523.tar.gz
Added cookie support to test browser
Diffstat (limited to 'paste/tests')
-rw-r--r--paste/tests/fixture.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/paste/tests/fixture.py b/paste/tests/fixture.py
index c5524d4..9cd007d 100644
--- a/paste/tests/fixture.py
+++ b/paste/tests/fixture.py
@@ -7,6 +7,7 @@ import cgi
import os
import warnings
import webbrowser
+from Cookie import SimpleCookie
try:
from cStringIO import StringIO
except ImportError:
@@ -332,6 +333,10 @@ class TestApp(object):
self.app = app
self.config = config
self.namespace = namespace
+ self.reset()
+
+ def reset(self):
+ self.cookies = {}
def make_environ(self):
environ = self.config.get('test_environ', {}).copy()
@@ -421,6 +426,11 @@ class TestApp(object):
% repr(file_info)[:100])
def do_request(self, req, status):
+ if self.cookies:
+ c = SimpleCookie()
+ for name, value in self.cookies.items():
+ c[name] = value
+ req.environ['HTTP_COOKIE'] = str(c).split(': ', 1)[1]
app = lint.middleware(self.app)
old_stdout = sys.stdout
out = StringIO()
@@ -438,6 +448,10 @@ class TestApp(object):
self.namespace['res'] = res
self.check_status(status, res)
self.check_errors(res)
+ for header in res.all_headers('set-cookie'):
+ c = SimpleCookie(header)
+ for key, morsel in c.items():
+ self.cookies[key] = morsel.value
if self.namespace is None:
# It's annoying to return the response in doctests, as it'll
# be printed, so we only return it is we couldn't assign