本文整理匯總了Python中Cookie.BaseCookie.update方法的典型用法代碼示例。如果您正苦於以下問題:Python BaseCookie.update方法的具體用法?Python BaseCookie.update怎麽用?Python BaseCookie.update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cookie.BaseCookie
的用法示例。
在下文中一共展示了BaseCookie.update方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TestAgent
# 需要導入模塊: from Cookie import BaseCookie [as 別名]
# 或者: from Cookie.BaseCookie import update [as 別名]
class TestAgent(object):
"""
A ``TestAgent`` object provides a user agent for the WSGI application under
test.
Key methods and properties:
- ``get(path)``, ``post(path)``, ``post_multipart`` - create get/post
requests for the WSGI application and return a new ``TestAgent`` object
- ``request``, ``response`` - the `werkzeug` request and
response objects associated with the last WSGI request.
- ``body`` - the body response as a string
- ``lxml`` - the lxml representation of the response body (only
applicable for HTML responses)
- ``reset()`` - reset the TestAgent object to its initial
state, discarding any form field values
- ``find()`` (or dictionary-style attribute access) - evalute the given
xpath expression against the current response body and return a list.
"""
response_class = wz.Response
_lxml= None
environ_defaults = {
'SCRIPT_NAME': "",
'PATH_INFO': "",
'QUERY_STRING': "",
'SERVER_NAME': "localhost",
'SERVER_PORT': "80",
'SERVER_PROTOCOL': "HTTP/1.0",
'REMOTE_ADDR': '127.0.0.1',
'wsgi.version': (1, 0),
'wsgi.url_scheme': 'http',
'wsgi.multithread': False,
'wsgi.multiprocess': False,
'wsgi.run_once': False,
}
def __init__(self, app, request=None, response=None, cookies=None, history=None, validate_wsgi=False):
# TODO: Make validate_wsgi pass
if validate_wsgi:
app = wsgi_validator(app)
self.app = app
self.request = request
self.response = response
self._elements = []
# Stores file upload field values in forms
self.file_uploads = {}
if cookies:
self.cookies = cookies
else:
self.cookies = BaseCookie()
if response:
self.cookies.update(parse_cookies(response))
if history:
self.history = history
else:
self.history = []
@classmethod
def make_environ(cls, REQUEST_METHOD='GET', PATH_INFO='', wsgi_input='', **kwargs):
SCRIPT_NAME = kwargs.pop('SCRIPT_NAME', cls.environ_defaults["SCRIPT_NAME"])
if SCRIPT_NAME and SCRIPT_NAME[-1] == "/":
SCRIPT_NAME = SCRIPT_NAME[:-1]
PATH_INFO = "/" + PATH_INFO
if not SCRIPT_NAME:
assert not PATH_INFO.startswith('.')
environ = cls.environ_defaults.copy()
environ.update(kwargs)
for key, value in kwargs.items():
environ[key.replace('wsgi_', 'wsgi.')] = value
if isinstance(wsgi_input, basestring):
wsgi_input = StringIO(wsgi_input)
environ.update({
'REQUEST_METHOD': REQUEST_METHOD,
'SCRIPT_NAME': SCRIPT_NAME,
'PATH_INFO': PATH_INFO,
'wsgi.input': wsgi_input,
'wsgi.errors': StringIO(),
})
if environ['SCRIPT_NAME'] == '/':
environ['SCRIPT_NAME'] = ''
environ['PATH_INFO'] = '/' + environ['PATH_INFO']
while PATH_INFO.startswith('//'):
PATH_INFO = PATH_INFO[1:]
#.........這裏部分代碼省略.........