本文整理汇总了Python中pyramid.testing.DummyRequest.headers['Range']方法的典型用法代码示例。如果您正苦于以下问题:Python DummyRequest.headers['Range']方法的具体用法?Python DummyRequest.headers['Range']怎么用?Python DummyRequest.headers['Range']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.testing.DummyRequest
的用法示例。
在下文中一共展示了DummyRequest.headers['Range']方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_range_return_max_return
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import headers['Range'] [as 别名]
def test_range_return_max_return(self):
items = range (9999)
req = DummyRequest()
req.headers['Range'] = 'items=0-9999'
filtered = range_return(req, items)
self.assertEquals(items[0:5000], filtered)
self.assertEqual(req.response.headers['Content-Range'], 'items 0-4999/9999')
items = range(14999)
req.headers['Range'] = 'items=5000-15000'
filtered = range_return(req, items)
self.assertEqual(items[5000:10000], filtered)
self.assertEqual(req.response.headers['Content-Range'], 'items 5000-9999/14999')
示例2: test_range_return_large_request
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import headers['Range'] [as 别名]
def test_range_return_large_request(self):
items = range(10)
req = DummyRequest()
req.headers['Range'] = 'items=0-100'
filtered = range_return(req, items)
self.assertEquals(items, filtered)
self.assertEquals(req.response.headers['Content-Range'], 'items 0-9/10')
示例3: test_range_return_x_or_not
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import headers['Range'] [as 别名]
def test_range_return_x_or_not(self):
items = range(10)
req = DummyRequest()
req.headers['Range'] = 'items=0-4'
filtered_no_x = range_return(req, items)
req_x = DummyRequest()
req_x.headers['X-Range'] = 'items=0-4'
filtered_x = range_return(req_x, items)
self.assertEquals(filtered_x, filtered_no_x)