本文整理汇总了Python中requests.cookies.morsel_to_cookie函数的典型用法代码示例。如果您正苦于以下问题:Python morsel_to_cookie函数的具体用法?Python morsel_to_cookie怎么用?Python morsel_to_cookie使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了morsel_to_cookie函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_max_age_invalid_str
def test_max_age_invalid_str(self):
"""Test case where a invalid max age is passed."""
morsel = Morsel()
morsel["max-age"] = "woops"
with pytest.raises(TypeError):
morsel_to_cookie(morsel)
示例2: test_expires_invalid_str
def test_expires_invalid_str(self):
"""Test case where an invalid string is input."""
morsel = Morsel()
morsel["expires"] = "woops"
with pytest.raises(ValueError):
morsel_to_cookie(morsel)
示例3: test_expires_invalid_int
def test_expires_invalid_int(self):
"""Test case where an invalid type is passed for expires."""
morsel = Morsel()
morsel["expires"] = 100
with pytest.raises(TypeError):
morsel_to_cookie(morsel)
示例4: test_max_age_valid_int
def test_max_age_valid_int(self):
"""Test case where a valid max age in seconds is passed."""
morsel = Morsel()
morsel["max-age"] = 60
cookie = morsel_to_cookie(morsel)
assert isinstance(cookie.expires, int)
示例5: test_expires_none
def test_expires_none(self):
"""Test case where expires is None."""
morsel = Morsel()
morsel["expires"] = None
cookie = morsel_to_cookie(morsel)
assert cookie.expires is None
示例6: test_expires_valid_str
def test_expires_valid_str(self):
"""Test case where we convert expires from string time."""
morsel = Morsel()
morsel["expires"] = "Thu, 01-Jan-1970 00:00:01 GMT"
cookie = morsel_to_cookie(morsel)
assert cookie.expires == 1
示例7: proceed
def proceed(self):
script = self.doc.xpath('//script/text()')[0]
cookieStr = re.match('.*document\.cookie = "([^"]+)".*',
script, re.DOTALL).group(1)
morsel = Cookie.Cookie(cookieStr).values()[0]
self.browser.session.cookies.set_cookie(morsel_to_cookie(morsel))
form = self.get_form()
return form.submit()
示例8: test_expires_invalid_int
def test_expires_invalid_int(self, value, exception):
"""Test case where an invalid type is passed for expires."""
morsel = Morsel()
morsel['expires'] = value
with pytest.raises(exception):
morsel_to_cookie(morsel)