def test_resource_headers_are_utf8(self):
resp = webob.Response(status_int=http.ACCEPTED)
resp.headers['x-header1'] = 1
resp.headers['x-header2'] = u'header2'
resp.headers['x-header3'] = u'header3'
class Controller(object):
def index(self, req):
return resp
req = webob.Request.blank('/tests')
app = fakes.TestRouter(Controller())
response = req.get_response(app)
for val in response.headers.values():
# All headers must be utf8
self.assertThat(val, matchers.EncodedByUTF8())
self.assertEqual(b'1', response.headers['x-header1'])
self.assertEqual(b'header2', response.headers['x-header2'])
self.assertEqual(b'header3', response.headers['x-header3'])
评论列表
文章目录