本文整理汇总了Python中ipapython.cookie.Cookie.http_return_ok方法的典型用法代码示例。如果您正苦于以下问题:Python Cookie.http_return_ok方法的具体用法?Python Cookie.http_return_ok怎么用?Python Cookie.http_return_ok使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ipapython.cookie.Cookie
的用法示例。
在下文中一共展示了Cookie.http_return_ok方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_httponly
# 需要导入模块: from ipapython.cookie import Cookie [as 别名]
# 或者: from ipapython.cookie.Cookie import http_return_ok [as 别名]
def test_httponly(self):
cookie = Cookie('color', 'blue', httponly=True)
self.assertTrue(cookie.http_return_ok('http://example.com'))
self.assertTrue(cookie.http_return_ok('https://example.com'))
with self.assertRaises(Cookie.URLMismatch):
self.assertTrue(cookie.http_return_ok('ftp://example.com'))
示例2: test_path
# 需要导入模块: from ipapython.cookie import Cookie [as 别名]
# 或者: from ipapython.cookie.Cookie import http_return_ok [as 别名]
def test_path(self):
cookie = Cookie('color', 'blue')
self.assertTrue(cookie.http_return_ok(self.url))
cookie = Cookie('color', 'blue', path='/')
self.assertTrue(cookie.http_return_ok(self.url))
cookie = Cookie('color', 'blue', path='/one')
self.assertTrue(cookie.http_return_ok(self.url))
cookie = Cookie('color', 'blue', path='/oneX')
with self.assertRaises(Cookie.URLMismatch):
self.assertTrue(cookie.http_return_ok(self.url))
示例3: test_expires
# 需要导入模块: from ipapython.cookie import Cookie [as 别名]
# 或者: from ipapython.cookie.Cookie import http_return_ok [as 别名]
def test_expires(self):
now = datetime.datetime.utcnow().replace(microsecond=0)
# expires 1 day from now
expires = now + datetime.timedelta(days=1)
cookie = Cookie('color', 'blue', expires=expires)
self.assertTrue(cookie.http_return_ok(self.url))
# expired 1 day ago
expires = now + datetime.timedelta(days=-1)
cookie = Cookie('color', 'blue', expires=expires)
with self.assertRaises(Cookie.Expired):
self.assertTrue(cookie.http_return_ok(self.url))
示例4: test_domain
# 需要导入模块: from ipapython.cookie import Cookie [as 别名]
# 或者: from ipapython.cookie.Cookie import http_return_ok [as 别名]
def test_domain(self):
cookie = Cookie('color', 'blue', domain='www.foo.bar.com')
self.assertTrue(cookie.http_return_ok(self.url))
cookie = Cookie('color', 'blue', domain='.foo.bar.com')
self.assertTrue(cookie.http_return_ok(self.url))
cookie = Cookie('color', 'blue', domain='.bar.com')
self.assertTrue(cookie.http_return_ok(self.url))
cookie = Cookie('color', 'blue', domain='bar.com')
with self.assertRaises(Cookie.URLMismatch):
self.assertTrue(cookie.http_return_ok(self.url))
cookie = Cookie('color', 'blue', domain='bogus.com')
with self.assertRaises(Cookie.URLMismatch):
self.assertTrue(cookie.http_return_ok(self.url))
cookie = Cookie('color', 'blue', domain='www.foo.bar.com')
with self.assertRaises(Cookie.URLMismatch):
self.assertTrue(cookie.http_return_ok('http://192.168.1.1/one/two'))
示例5: test_secure
# 需要导入模块: from ipapython.cookie import Cookie [as 别名]
# 或者: from ipapython.cookie.Cookie import http_return_ok [as 别名]
def test_secure(self):
cookie = Cookie('color', 'blue', secure=True)
self.assertTrue(cookie.http_return_ok('https://Xexample.com'))
with self.assertRaises(Cookie.URLMismatch):
self.assertTrue(cookie.http_return_ok('http://Xexample.com'))
示例6: test_no_attributes
# 需要导入模块: from ipapython.cookie import Cookie [as 别名]
# 或者: from ipapython.cookie.Cookie import http_return_ok [as 别名]
def test_no_attributes(self):
cookie = Cookie('color', 'blue')
self.assertTrue(cookie.http_return_ok(self.url))