当前位置: 首页>>代码示例>>Python>>正文


Python DummyRequest.headers方法代码示例

本文整理汇总了Python中pyramid.testing.DummyRequest.headers方法的典型用法代码示例。如果您正苦于以下问题:Python DummyRequest.headers方法的具体用法?Python DummyRequest.headers怎么用?Python DummyRequest.headers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyramid.testing.DummyRequest的用法示例。


在下文中一共展示了DummyRequest.headers方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_bool_json_body

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import headers [as 别名]
 def test_bool_json_body(self):
     """ Pull bool params out of json body """
     request = DummyRequest()
     request.params = {}
     request.headers = {'Content-Type': 'application/json'}
     request.json_body = {'field': True}
     field = param(request, 'field', type=bool)
     self.assertTrue(field is True)
开发者ID:stevearc,项目名称:pyramid_duh,代码行数:10,代码来源:test_params.py

示例2: test_set_json_body

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import headers [as 别名]
 def test_set_json_body(self):
     """ Pull set params out of json body """
     request = DummyRequest()
     request.params = {}
     request.json_body = {'field': set(['a', 'b'])}
     request.headers = {'Content-Type': 'application/json'}
     field = param(request, 'field', type=set)
     self.assertEquals(field, set(['a', 'b']))
开发者ID:stevearc,项目名称:pyramid_duh,代码行数:10,代码来源:test_params.py

示例3: test_dict_json_body

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import headers [as 别名]
 def test_dict_json_body(self):
     """ Pull dict params out of json body """
     request = DummyRequest()
     request.params = {}
     request.json_body = {'field': {'a': 'b'}}
     request.headers = {'Content-Type': 'application/json'}
     field = param(request, 'field', type=dict)
     self.assertEquals(field, {'a': 'b'})
开发者ID:stevearc,项目名称:pyramid_duh,代码行数:10,代码来源:test_params.py

示例4: test_list_json_body

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import headers [as 别名]
 def test_list_json_body(self):
     """ Pull list params out of json body """
     request = DummyRequest()
     request.params = {}
     request.json_body = {'field': [1, 2, 3]}
     request.headers = {'Content-Type': 'application/json'}
     field = param(request, 'field', type=list)
     self.assertEquals(field, [1, 2, 3])
开发者ID:stevearc,项目名称:pyramid_duh,代码行数:10,代码来源:test_params.py

示例5: test_unicode_json_body

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import headers [as 别名]
 def test_unicode_json_body(self):
     """ Pull unicode params out of json body """
     request = DummyRequest()
     request.params = {}
     request.json_body = {'field': 'myfield'}
     request.headers = {'Content-Type': 'application/json'}
     field = param(request, 'field')
     self.assertEquals(field, 'myfield')
     self.assertTrue(isinstance(field, six.text_type))
开发者ID:stevearc,项目名称:pyramid_duh,代码行数:11,代码来源:test_params.py

示例6: test_datetime_json_body

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import headers [as 别名]
 def test_datetime_json_body(self):
     """ Pull datetime params out of json body """
     request = DummyRequest()
     request.params = {}
     now = int(time.time())
     request.json_body = {'field': now}
     request.headers = {'Content-Type': 'application/json'}
     field = param(request, 'field', type=datetime)
     self.assertEquals(calendar.timegm(field.utctimetuple()), now)
开发者ID:stevearc,项目名称:pyramid_duh,代码行数:11,代码来源:test_params.py

示例7: test_str_json_body

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import headers [as 别名]
 def test_str_json_body(self):
     """ Pull str params out of json body """
     request = DummyRequest()
     request.params = {}
     request.json_body = {'field': 'myfield'}
     request.headers = {'Content-Type': 'application/json'}
     field = param(request, 'field', type=bytes)
     self.assertEquals(field, b'myfield')
     self.assertTrue(isinstance(field, six.binary_type))
开发者ID:stevearc,项目名称:pyramid_duh,代码行数:11,代码来源:test_params.py

示例8: test_kwargs_json_body

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import headers [as 别名]
 def test_kwargs_json_body(self):
     """ argify will pass extra kwargs in **kwargs in json body """
     @argify
     def req(request, f1, f2=None, **kwargs):
         self.assertEquals(f1, 'bar')
         self.assertEquals(kwargs, {'foobar': 'baz'})
     context = object()
     request = DummyRequest()
     request.params = {}
     request.headers = {'Content-Type': 'application/json'}
     request.json_body = {
         'f1': 'bar',
         'foobar': 'baz',
     }
     req(context, request)
开发者ID:stevearc,项目名称:pyramid_duh,代码行数:17,代码来源:test_params.py


注:本文中的pyramid.testing.DummyRequest.headers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。