unit test fixes #nolog

This commit is contained in:
Miguel Grinberg
2022-09-17 20:46:11 +01:00
parent 75725795b4
commit 59453a52a1
2 changed files with 4 additions and 1 deletions

View File

@@ -21,7 +21,7 @@ class TestResponse(BaseTestResponse):
async def _initialize_body(self, res):
self.body = b''
async for body in res.body_iter():
async for body in res.body_iter(): # pragma: no branch
if isinstance(body, str):
body = body.encode()
self.body += body

View File

@@ -238,14 +238,17 @@ class TestResponse(unittest.TestCase):
def test_default_content_type(self):
original_content_type = Response.default_content_type
res = Response('foo')
res.complete()
self.assertEqual(res.headers['Content-Type'],
'text/plain; charset=UTF-8')
Response.default_content_type = 'text/html'
res = Response('foo')
res.complete()
self.assertEqual(res.headers['Content-Type'],
'text/html; charset=UTF-8')
Response.default_content_type = 'text/html; charset=ISO-8859-1'
res = Response('foo')
res.complete()
self.assertEqual(res.headers['Content-Type'],
'text/html; charset=ISO-8859-1')
Response.default_content_type = original_content_type