本文整理汇总了Python中webob.response.Response.__setattr__方法的典型用法代码示例。如果您正苦于以下问题:Python Response.__setattr__方法的具体用法?Python Response.__setattr__怎么用?Python Response.__setattr__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webob.response.Response
的用法示例。
在下文中一共展示了Response.__setattr__方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_text_set_not_unicode
# 需要导入模块: from webob.response import Response [as 别名]
# 或者: from webob.response.Response import __setattr__ [as 别名]
def test_text_set_not_unicode():
res = Response()
res.charset = 'utf-8'
with pytest.raises(TypeError):
res.__setattr__('text',
b'La Pe\xc3\xb1a')
示例2: test_charset_set_no_content_type_header
# 需要导入模块: from webob.response import Response [as 别名]
# 或者: from webob.response.Response import __setattr__ [as 别名]
def test_charset_set_no_content_type_header():
res = Response()
res.headers.pop('Content-Type', None)
with pytest.raises(AttributeError):
res.__setattr__('charset', 'utf-8')
示例3: test_text_set_no_charset
# 需要导入模块: from webob.response import Response [as 别名]
# 或者: from webob.response.Response import __setattr__ [as 别名]
def test_text_set_no_charset():
res = Response()
res.charset = None
with pytest.raises(AttributeError):
res.__setattr__('text', 'abc')
示例4: test_body_set_unicode
# 需要导入模块: from webob.response import Response [as 别名]
# 或者: from webob.response.Response import __setattr__ [as 别名]
def test_body_set_unicode():
res = Response()
with pytest.raises(TypeError):
res.__setattr__('body', text_(b'abc'))
示例5: test_body_set_not_unicode_or_str
# 需要导入模块: from webob.response import Response [as 别名]
# 或者: from webob.response.Response import __setattr__ [as 别名]
def test_body_set_not_unicode_or_str():
res = Response()
with pytest.raises(TypeError):
res.__setattr__('body', object())
示例6: test_text_set_not_unicode
# 需要导入模块: from webob.response import Response [as 别名]
# 或者: from webob.response.Response import __setattr__ [as 别名]
def test_text_set_not_unicode():
res = Response()
res.charset = "utf-8"
with pytest.raises(TypeError):
res.__setattr__("text", b"La Pe\xc3\xb1a")