convert header values to strings

This commit is contained in:
Raphael Deem
2016-12-13 21:24:26 -08:00
parent ef9d8710f5
commit 7e6c92dc52
2 changed files with 29 additions and 1 deletions

View File

@@ -32,6 +32,32 @@ def test_text():
assert response.text == 'Hello'
def test_headers():
app = Sanic('test_text')
@app.route('/')
async def handler(request):
headers = {"spam": "great"}
return text('Hello', headers=headers)
request, response = sanic_endpoint_test(app)
assert response.headers.get('spam') == 'great'
def test_invalid_headers():
app = Sanic('test_text')
@app.route('/')
async def handler(request):
headers = {"answer": 42}
return text('Hello', headers=headers)
request, response = sanic_endpoint_test(app)
assert response.headers.get('answer') == '42'
def test_json():
app = Sanic('test_json')