本文整理汇总了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:]
#.........这里部分代码省略.........