def test_text_set_not_unicode(): res = Response() res.charset = 'utf-8' with pytest.raises(TypeError): res.__setattr__('text', b'La Pe\xc3\xb1a')
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')
def test_body_set_unicode(): res = Response() with pytest.raises(TypeError): res.__setattr__('body', text_(b'abc'))
def test_text_set_no_charset(): res = Response() res.charset = None with pytest.raises(AttributeError): res.__setattr__('text', 'abc')
def test_body_set_not_unicode_or_str(): res = Response() with pytest.raises(TypeError): res.__setattr__('body', object())
def test_text_set_not_unicode(): res = Response() res.charset = "utf-8" with pytest.raises(TypeError): res.__setattr__("text", b"La Pe\xc3\xb1a")
def test_body_set_unicode(): res = Response() with pytest.raises(TypeError): res.__setattr__("body", text_(b"abc"))