本文整理汇总了Python中django.http.HttpRequest.GET['format']方法的典型用法代码示例。如果您正苦于以下问题:Python HttpRequest.GET['format']方法的具体用法?Python HttpRequest.GET['format']怎么用?Python HttpRequest.GET['format']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.http.HttpRequest
的用法示例。
在下文中一共展示了HttpRequest.GET['format']方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_xml_parameter_get
# 需要导入模块: from django.http import HttpRequest [as 别名]
# 或者: from django.http.HttpRequest import GET['format'] [as 别名]
def test_xml_parameter_get(self):
req = HttpRequest()
req.GET['format'] = '1'
resp = widget(lambda r: "test")(req)
self.assertEqual('<?xml version="1.0" ?><root>test</root>',
resp.content)
self.assertEqual(resp._headers['content-type'], ('Content-Type', 'application/xml'))
示例2: test_encrypted_json_get
# 需要导入模块: from django.http import HttpRequest [as 别名]
# 或者: from django.http.HttpRequest import GET['format'] [as 别名]
def test_encrypted_json_get(self):
req = HttpRequest()
req.GET['format'] = '2'
resp = widget(encrypted=True)(lambda r: "test")(req)
self.assertNotEqual('"test"', resp.content)
self.assertEqual(44, len(resp.content))
self.assertEqual(resp._headers['content-type'], ('Content-Type', 'application/json'))
示例3: test10_test_format
# 需要导入模块: from django.http import HttpRequest [as 别名]
# 或者: from django.http.HttpRequest import GET['format'] [as 别名]
def test10_test_format(self):
request = HttpRequest()
request.method = 'GET'
request.GET['format'] = 'json'
cr = CustomAPIResource()
the_ret = cr.get_schema(request)
self.assertEqual(
the_ret._headers['content-type'][1],
'application/json; charset=utf-8')
示例4: test_encrypted_xml_get
# 需要导入模块: from django.http import HttpRequest [as 别名]
# 或者: from django.http.HttpRequest import GET['format'] [as 别名]
def test_encrypted_xml_get(self):
req = HttpRequest()
req.GET['format'] = '1'
self.assertRaises(ValueError, widget(encrypted=True)(lambda r: "test"), req)
示例5: test_json_parameter_get
# 需要导入模块: from django.http import HttpRequest [as 别名]
# 或者: from django.http.HttpRequest import GET['format'] [as 别名]
def test_json_parameter_get(self):
req = HttpRequest()
req.GET['format'] = '2'
resp = widget(lambda r: "test")(req)
self.assertEqual('"test"', resp.content)
self.assertEqual(resp._headers['content-type'], ('Content-Type', 'application/json'))
示例6: test_json_get
# 需要导入模块: from django.http import HttpRequest [as 别名]
# 或者: from django.http.HttpRequest import GET['format'] [as 别名]
def test_json_get(self):
req = HttpRequest()
req.GET['format'] = '2'
resp = widget(lambda r: "test")(req)
self.assertEqual('"test"', resp.content)
示例7: test_xml_get
# 需要导入模块: from django.http import HttpRequest [as 别名]
# 或者: from django.http.HttpRequest import GET['format'] [as 别名]
def test_xml_get(self):
req = HttpRequest()
req.GET['format'] = '1'
resp = widget(lambda r: "test")(req)
self.assertEqual('<?xml version="1.0" ?><root>test</root>',
resp.content)